[Django] #33243: Inline comment vanishes in parsed template, comment block is represented as CommentNode

6 views
Skip to first unread message

Django

unread,
Oct 30, 2021, 5:20:06 AM10/30/21
to django-...@googlegroups.com
#33243: Inline comment vanishes in parsed template, comment block is represented as
CommentNode
-------------------------------------------+------------------------
Reporter: D. W. | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
When parsing a template via

{{{#!python
from django.template import Template
template1 = Template('{# inline comment #}')
template2 = Template('{% comment %}block comment{% endblock %}')
}}}

the nodelist of the inline comment '''{# ... #}''' will be empty, but the
nodelist of the block comment '''{% comment %}...{% endcomment %}''' will
show the CommentNode.

{{{#!python
print(template1.nodelist)
# -> []
print(template2.nodelist)
# -> [<django.template.defaulttags.CommentNode object at 0x...>]
}}}

The inline comment should also be visible in the nodelist ... as a
CommentNode oder an InlineCommentNode.

--
Ticket URL: <https://code.djangoproject.com/ticket/33243>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 2, 2021, 5:11:30 AM11/2/21
to django-...@googlegroups.com
#33243: Inline comment vanishes in parsed template, comment block is represented as
CommentNode
---------------------------------+--------------------------------------

Reporter: D. W. | Owner: nobody
Type: New feature | Status: closed

Component: Template system | Version: 4.0
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* type: Bug => New feature
* resolution: => wontfix


Comment:

The behaviour here has been
[https://github.com/django/django/blob/60b46d72ac81dc5a54b4eaa8ccf1159f83666aa9/django/template/__init__.py#L241-L270
unchanged since the `{# inline comment #}` syntax was introduced] for
#648. I don't think a change is justified; I'd certainly want to see some
consensus for that on the DevelopersMailingList before proceeding.

--
Ticket URL: <https://code.djangoproject.com/ticket/33243#comment:1>

Reply all
Reply to author
Forward
0 new messages