djangosnippets.org: Latest snippets posted by ctrochalakishttps://djangosnippets.org/users/ctrochalakis/2009-08-26T12:57:32.470342-05:00ctrochalakisEnhancing template tags with "as variable" syntax
2009-08-26T12:57:32.470342-05:00ctrochalakishttps://djangosnippets.org/snippets/1701/<p>Add the decorator to an already defined templatetag that returns a Node object:</p>
<pre><code>@with_as
def do_current_time(parser, token):
...
return a_node
</code></pre>
<p>The decorator will patch the node's render method when the "as" syntax is specified and will update the context with the new variable. The following syntaxes are available:</p>
<pre><code>{% current_time …</code></pre>
Freely redistributable