Ticket #6898: templates_python.txt.diff

File templates_python.txt.diff, 1022 bytes (added by Djoume Salvetti, 17 years ago)
  • templates_python.txt

     
    10591059
    10601060Although you can pass any number of arguments to a template tag using
    10611061``token.split_contents()``, the arguments are all unpacked as
    1062 string literals. A little more work is required in order to dynamic content (a
    1063 template variable) to a template tag as an argument.
     1062string literals. A little more work is required in order to pass dynamic
     1063content (a template variable) to a template tag as an argument.
    10641064
    10651065While the previous examples have formatted the current time into a string and
    10661066returned the string, suppose you wanted to pass in a ``DateTimeField`` from an
     
    11691169In Python 2.4, the decorator syntax also works::
    11701170
    11711171    @register.simple_tag
    1172     def current_time(token):
     1172    def current_time(format_string):
    11731173        ...
    11741174
    11751175A couple of things to note about the ``simple_tag`` helper function:
Back to Top