framework: Nunjucks Multilevel Template Inheritance is broken
- Maizzle Version: 0.4.4
- Node.js Version: 12.13.1
Description:
Inheritance between templates doesn’t work.
You can find the feature’s documentation here: Nunjucks (https://mozilla.github.io/nunjucks/templating.html#template-inheritance) and Jinja (https://jinja.palletsprojects.com/en/2.10.x/templates/#template-inheritance)
This is caused by the code who extends the layout for all templates.
#node_modules/@maizzle/framework/src/generators/output/toDisk.js:60
html = `{% extends “${layout}” %}\n${frontMatter.body}`
Some solutions could be to skip layout inclusion if the template contains {% extends, “layout” setting is explicitly set to false or a setting doNotExtendsLayout is set.
Steps To Reproduce:
Extends a file or a template with another template and build.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 41 (21 by maintainers)
This. You need to always declare the layout you’re extending, if you use inheritance (extending a template from a template). Just tested and it works as expected, so I’ll close this as resolved - feel free to reopen if you spot other issues with it. And big thanks to both of you for your help ✌
Fixed it, will publish soon. @lowv-developer managed to preserve the ‘automagic’ of layout extending - you should only be required to specify the
layoutkey only if your template is being extended by another template.I tried, it, answered there in #74 . Not only does it not compile that template that extends a template, but I don’t want users to have to add workarounds like this, with
falseand{% extends %}.Thanks for the PR, but I think I’m just going to make specifying a
layout:mandatory. It’s not a big deal and it doesn’t do any magic stuff, which I think is better.Fixed it, should work as expected now. Feel free to reopen if you spot any issues ✌
Yes, of course, the issue still stands - just wanted to have it mentioned. Would love to see a PR, but yeah please wait until I publish the new release. Thanks!
Perfect gonna follow the updates cause we are very interest to this framework!