Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #16939 -- Inaccurate implementation of {% comment %} presented …

…in custom template tag 'howto' guide. Thanks sebastian for the patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent ad97f0e commit 5ccc6f17b8452ef1377755d21148036dc0c88ba0 @SmileyChris SmileyChris committed
10 docs/howto/custom-template-tags.txt
@@ -1155,7 +1155,7 @@ Template tags can work in tandem. For instance, the standard
To create a template tag such as this, use ``parser.parse()`` in your
compilation function.
-Here's how the standard :ttag:`{% comment %}<comment>` tag is implemented:
+Here's how a simplified ``{% comment %}`` tag might be implemented:
.. code-block:: python
@@ -1168,6 +1168,14 @@ Here's how the standard :ttag:`{% comment %}<comment>` tag is implemented:
def render(self, context):
return ''
+.. note::
+ The actual implementation of :ttag:`{% comment %}<comment>` is slightly
+ different in that it allows broken template tags to appear between
+ ``{% comment %}`` and ``{% endcomment %}``. It does so by calling
+ ``parser.skip_past('endcomment')`` instead of ``parser.parse(('endcomment',))``
+ followed by ``parser.delete_first_token()``, thus avoiding the generation of a
+ node list.
``parser.parse()`` takes a tuple of names of block tags ''to parse until''. It
returns an instance of ``django.template.NodeList``, which is a list of
all ``Node`` objects that the parser encountered ''before'' it encountered
2  docs/ref/templates/builtins.txt
@@ -51,7 +51,7 @@ Defines a block that can be overridden by child templates. See
-Ignores everything between ``{% comment %}`` and ``{% endcomment %}``
+Ignores everything between ``{% comment %}`` and ``{% endcomment %}``.
.. templatetag:: csrf_token

0 comments on commit 5ccc6f1

Please sign in to comment.
Something went wrong with that request. Please try again.