Login

Snippets by ctrochalakis

Snippet List

Enhancing template tags with "as variable" syntax

Add the decorator to an already defined templatetag that returns a Node object: @with_as def do_current_time(parser, token): ... return a_node 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: {% current_time %} {% current_time as time %} {{ time }}

  • templates
  • templatetags
Read More

ctrochalakis has posted 1 snippet.