Ticket #16939: r17141-howto-custom-template-tags-comment.diff
File r17141-howto-custom-template-tags-comment.diff, 1.6 KB (added by , 13 years ago) |
---|
-
docs/howto/custom-template-tags.txt
1155 1155 To create a template tag such as this, use ``parser.parse()`` in your 1156 1156 compilation function. 1157 1157 1158 Here's how the standard :ttag:`{% comment %}<comment>` tag isimplemented:1158 Here's how a simplified ``{% comment %}`` tag might be implemented: 1159 1159 1160 1160 .. code-block:: python 1161 1161 … … 1168 1168 def render(self, context): 1169 1169 return '' 1170 1170 1171 .. note:: 1172 The actual implementation of :ttag:`{% comment %}<comment>` is slightly 1173 different in that it allows broken template tags to appear between 1174 ``{% comment %}`` and ``{% endcomment %}``. It does so by calling 1175 ``parser.skip_past('endcomment')`` instead of ``parser.parse(('endcomment',))`` 1176 followed by ``parser.delete_first_token()``, thus avoiding the generation of a 1177 node list. 1178 1171 1179 ``parser.parse()`` takes a tuple of names of block tags ''to parse until''. It 1172 1180 returns an instance of ``django.template.NodeList``, which is a list of 1173 1181 all ``Node`` objects that the parser encountered ''before'' it encountered -
docs/ref/templates/builtins.txt
51 51 comment 52 52 ^^^^^^^ 53 53 54 Ignores everything between ``{% comment %}`` and ``{% endcomment %}`` 54 Ignores everything between ``{% comment %}`` and ``{% endcomment %}``. 55 55 56 56 .. templatetag:: csrf_token 57 57