Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override blocks in included templates #169

Closed
dwt opened this issue Jan 8, 2013 · 3 comments
Closed

Cannot override blocks in included templates #169

dwt opened this issue Jan 8, 2013 · 3 comments

Comments

@dwt
Copy link

dwt commented Jan 8, 2013

We're trying to override a block in an included template like this:

#included.jinja2

{% block master %}
    Default master content
{% endblock %}
#base.jinja2
{% include "included.jinja2" %}
{% include "included.jinja2" with context %}

{% block master %}
Fnord
{% endblock master %}
#hello.jinja2
{% extends "base.jinja2" %}

{% block master %}

Overridden master content

{% endblock master %}

When running the hello.jinja2 file we see this output

    Default master content
    Default master content
Overridden master content

I would have expected at least the second default master content to be replaced by the overriden content.

That I think is the bug.

@mitsuhiko
Copy link
Contributor

Duplicate.

@rbu
Copy link

rbu commented May 28, 2013

of?

Edit: Which issue is this a duplicate of?

@tony
Copy link

tony commented Nov 29, 2017

ugh, to make matters worse, Django templates don't do it either (see note at the end: https://docs.djangoproject.com/en/1.11/ref/templates/builtins/#include)

i thought maybe jinja2 would, it'd save me a heck of a lot of duplication >_<

anyway, I guess I'll just have to find a way to simplify stuff down :(

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants