Answer the question
In order to leave comments, you need to log in
How to load a template from a folder by category url in JADE?
I have about 30 categories and each category has its own html code structure, now in the template directory I use the elements.jade file, which in turn pulls the necessary template.
For example
if( ! catalog.url)
.data Catalog not found
if(catalog.url = 'cat')
.data Тут вывод определенного текста и HTML кода принадлежащего каталогу cat
if(catalog.url = 'cat2')
.data Тут вывод определенного текста и HTML кода принадлежащего каталогу cat2
./elements/cat.jade
./elements/cat2.jade
for(i; i < data.length;i++) {
-var x = data[i];
// тут какой то код
// Тут надо подгрузить шаблон, что то вроде
include ./elements/#{x.catalog.url} // понятно что не работает, но зато наглядно отражает что хочется сделать
// тут тоже какой то код
}
Answer the question
In order to leave comments, you need to log in
Found a solution.
On the backend
var jade = require('jade');
.......
res.render('index', {templateRender: jade.renderFile});
!= templateRender('полный путь до файл' + template + '.jade', options)
The last time I tried it was impossible. The parser simply treats what comes after the include as a static string, and that's it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question