id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 398 [patch] {%define VAR as%}VALUE{%in%} tag jvr_django@… Adrian Holovaty "I submit two patches. The first patch modifies Parser.parse() to optionally pass its parse_until context to the do_* callbacks. This allows template tags to have scopes which are ended implicitly by the end of the enclosing scope. The second patch defines a {% define VAR as %} VALUE {% in %} construct. A typical use is: {{{ {% define title_var as%} {% block title %}The default title{% endblock %} {% in %} {{title_var}}

{{title_var}}

... }}} Here, by redefining the title block, a template can set the title BOTH in the and the of the page. Many other uses are possible. Note that this is not an attempt to turn the Django template system into a full-fledged programming language, it's just sometimes convenient to declare a name for a value and refer to it later. I have put the define-tag in defaulttags.py because I feel that, as a language construct, defining new variable bindings is at the same level as FOR loops and IF statements. If you do not agree, I hope you will still accept the first patch, because it will allow me to put this define-tag in my own apps and still use them with a standard Django installation. (The define-tag uses the implicit ending feature introduced by the first patch.) " enhancement closed Template system normal wontfix Design decision needed 1 0 0 0 0 0