Jinja2 Does Not Render Blocks
Solution 1:
You are implementing each block in a different html file, but you render index.html
. What Jinja2 does when you tell it to render index.html
is grab the base template (base.html
) and look at what modification index.html
brings - in your case, updating the content
block.
Jinja2 won't even look at the other block implementations (in other words the other html files) in this case. What you want is to implement title/navigation/etc. in base.html
itself. The templating engine only looks at the inheritance chain of the template you are currently rendering, it doesn't load all existing templates for each render operation.
EDIT: Discussed in comments but updating here in case some else runs into this: if you want to render different pieces from different files, use the {%include <template> %}
directive, not blocks.
Post a Comment for "Jinja2 Does Not Render Blocks"