Opened 3 years ago

Closed 3 years ago

#33243 closed New feature (wontfix)

Inline comment vanishes in parsed template, comment block is represented as CommentNode

Reported by: D. W. Owned by: nobody
Component: Template system Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When parsing a template via

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.

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.

Change History (1)

comment:1 by Carlton Gibson, 3 years ago

Resolution: wontfix
Status: newclosed
Type: BugNew feature

The behaviour here has been 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.

Note: See TracTickets for help on using tickets.
Back to Top