Answer the question
In order to leave comments, you need to log in
How to add spaces?
The problem is actually .... The task is to assemble the page from blocks, which means you need to use dynamic include. But out of the box, the pug won't let you do that. Therefore, I use the custom includeBlock function.
index.pug:
body
h2 Test
each item, name in blocksList
!= includeBlock('blocks/' + item.path)
<body>
<h2>Test</h2>
Content included blocks
</body>
pug({
pretty: true,
pug: pug.default,
data: {
blocksList: list,
includeBlock: function (_path, params) {
return pug.default.renderFile(path.default.dir.pug + '/' + _path, {
pretty: true,
locals: params || {}
});
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question