Consider the following templates and behavior.
==== File:parent-base.jinja ====
<!doctype html>
<html>
<head></head>
<body>
{% block debug %}{% endblock debug %}
{% block body scoped %}{% endblock body %}
</body>
</html>
==== File:parent.jinja ====
{% extends 'myapp/parent-base.jinja' %} {# This will be toggled on/off in
the output below #}
{% set X = '1234' %}
{% block debug %}
<pre>parent::X: '{{X}}'</pre>
{% endblock debug %}
{% block body scoped %}
<pre>{% include "companies/child.jinja" %}</pre>
{% endblock body %}
==== File:child.jinja ====
---- child::X: {{X}}
==== Rendered output with `extends` included ====
<!doctype html>
<html>
<head></head>
<body>
<pre>parent::X: '1234'</pre>
<pre>---- child::X: </pre>
</body>
</html>
==== Rendered output without `extends` ====
<pre>parent::X: '1234'</pre>
<pre>---- child::X: 1234</pre>
I would assume based on the documentation that a scoped block would remain
scoped whether or not a base template has been extended and it's overriding
a parent block. Yet if the parent.jinja template extends the base template
the value of the `set` variable X is not passed to the included child.jinja
template. I would expect it to pass the X var in and for it to display
correctly in the child template, as it does if extends is not used. If this
behavior is documented or correct I'd love to know why Jinja works that way
and to see that documentation. It's confusing to me that my block, which is
declared scoped in both the base template and the overriding template, is
considered unscoped if I extend.
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/groups/opt_out.