Ticket #7374: docs-simpletag.diff
File docs-simpletag.diff, 1.4 KB (added by , 16 years ago) |
---|
-
docs/templates_python.txt
890 890 891 891 Thus, to define a custom template tag, you specify how the raw template tag is 892 892 converted 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 895 and variables resolution for you, automatically. 894 896 895 897 Writing the compilation function 896 898 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 1251 1253 making it a pain for template authors to pass in all the arguments and remember 1252 1254 their order. To solve this, Django provides a ``takes_context`` option for 1253 1255 inclusion 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. 1256 the tag will have no required arguments, and the underlying Python function's 1257 first argument will be the template context as of when the tag was called. 1258 Of course, you can still have additional arguments. 1256 1259 1257 1260 For example, say you're writing an inclusion tag that will always be used in a 1258 1261 context that contains ``home_link`` and ``home_title`` variables that point