SHARE
TWEET

Untitled

a guest Feb 22nd, 2012 62 Never
  1. Consider this structure, used with latest Jinja from installed from PIP:
  2.  
  3. `base.html`
  4.     {% set var1 = True %}
  5.     {% set var2 = True %}
  6.     {% block one %}{% endblock %}
  7.  
  8. `index.html`
  9.     {% extends 'base.html' %}
  10.     {% block one %}
  11.         {% if var1 %}
  12.             {% include 'table.html' %}
  13.         {% endif %}
  14.     {% endblock %}
  15.  
  16. `table.html`
  17.     {{ var1 }}{{ var2 }}
  18.  
  19. When rendering index.html, it shows only 'True ' (= nothing for `var2`)
  20.  
  21. If I modify `index.html` to be :
  22.  
  23.     {% extends 'base.html' %}
  24.     {% block one %}
  25.         <!-- {{ var2 }} -->
  26.         {% if var1 %}
  27.             {% include 'table.html' %}
  28.         {% endif %}
  29.     {% endblock %}
  30.  
  31. Then everything is fine in `table.html` and the 2 vars show correctly.
  32.  
  33. Using {% include 'table.html' with context %} doesn't resolve the problem.
  34.  
  35. What did I miss ?
RAW Paste Data
Top