Le 17/02/2012 01:10, James Thornton a écrit :
Jinja2 2.6 is installed, and I'm customizing the rst_display.html template in rstblog.

I want to set a simple variable in rst_display.html so that it's available in layout.html:

rst_display.html:
{% extends "layout.html" %}
{% set name = "James" %}

layout.html:
Hello {{ name }}

However, "name" is blank in the generated HTML, but it works when you put the set statement directly in layout.html.

What could cause sets not to show in the parent?

Hi,

I’m not sure what the scoping rules for {% set %} are exactly, but you can use inheritance instead:

rst_display.html:
{% extends "layout.html" %}
{% block name %}James{% endblock %}

layout.html:
Hello {% block name %}(default name){% endblock %}

Regards,

--
Simon Sapin

--
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en.

Reply via email to