Closed angelside closed 1 year ago
I have to dig into the nunjucks internals code and see if it's possible to include the blocks defined in one template into another.
I have been trying to implement this but looks like it's not possible because it breaks other things.
A solution for your use case is creating a preprocessor to add the extends
directive. For example:
site.preprocess([".njk"], (page) => {
// Add the extends directive with the layout
page.data.content = `{% extends "${page.data.layout}" %}\n${page.data.content}`;
// Delete the layout from the frontmatter
delete page.data.layout;
});
Version
1.12.1
Platform
Arch Linux
What steps will reproduce the bug?
What do you see instead?
Additional information
Block and super structure not working with default frontmatter layout definition.
But, it's working if replacing frontmatter with classic nunjucks extends (Which is not the desired method, I like to use single data.yml file for layout).
Docs: https://mozilla.github.io/nunjucks/templating.html#template-inheritance Minimal example: https://github.com/angelside/lume-block-test
layout.njk
index.njk