This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 22nd, 2012  |  syntax: D  |  size: 0.84 KB  |  views: 61  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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 ?
clone this paste RAW Paste Data