Ticket #7374: docs-simpletag.diff

File docs-simpletag.diff, 1.4 KB (added by Waldemar Kornewald, 16 years ago)

minor improvement; on the long run the whole docs should be restructured

  • docs/templates_python.txt

     
    890890
    891891Thus, to define a custom template tag, you specify how the raw template tag is
    892892converted into a ``Node`` (the compilation function), and what the node's
    893 ``render()`` method does.
     893``render()`` method does. In many cases you can alternatively use the
     894``simple_tag`` and ``inclusion_tag`` shortcuts which do the argument parsing
     895and variables resolution for you, automatically.
    894896
    895897Writing the compilation function
    896898~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    12511253making it a pain for template authors to pass in all the arguments and remember
    12521254their order. To solve this, Django provides a ``takes_context`` option for
    12531255inclusion tags. If you specify ``takes_context`` in creating a template tag,
    1254 the tag will have no required arguments, and the underlying Python function
    1255 will have one argument -- the template context as of when the tag was called.
     1256the tag will have no required arguments, and the underlying Python function's
     1257first argument will be the template context as of when the tag was called.
     1258Of course, you can still have additional arguments.
    12561259
    12571260For example, say you're writing an inclusion tag that will always be used in a
    12581261context that contains ``home_link`` and ``home_title`` variables that point
Back to Top