Opened 9 months ago

Last modified 10 days ago

#36658 assigned New feature

Invalid numeric literal in an {% if %} tag is treated as a variable

Reported by: Lily Owned by: diaxoaine
Component: Template system Version: 5.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I would expect the following template to raise a TemplateSyntaxError during parsing:

{% if 1.1.1 %}foo{% endif %}

Instead, the 1.1.1 is treated as a variable name, so this will render an empty string (or "foo" if the context looks like {"1": {"1": {"1": "bar"}}} or similar).

Change History (9)

comment:2 by Natalia Bidart, 9 months ago

Easy pickings: unset
Resolution: wontfix
Status: newclosed
Type: BugNew feature

Hello Lily, thank you for your ticket. Please note that this is well documented, well tested behavior. Any change in this area should be widely discussed and agreed with the Django community, with a clear deprecation plan. The current semantic has been in place for ages and it's more than likely that many projects out there rely on this behavior.

Since this can't be treated as a bug nor as a cleanup, this qualifies as a New Feature, so this idea should first be proposed and discussed with the community. To do that, please raise this on the new feature tracker.

I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.

comment:3 by Lily, 6 weeks ago

Resolution: wontfix
Status: closednew

This was discussed and accepted in https://github.com/django/new-features/issues/116.

comment:4 by Sarah Boyce, 5 weeks ago

Triage Stage: UnreviewedAccepted

comment:5 by Sarah Boyce, 5 weeks ago

Has patch: unset

comment:6 by diaxoaine, 2 weeks ago

Owner: set to diaxoaine
Status: newassigned

comment:7 by diaxoaine, 12 days ago

Owner: diaxoaine removed
Status: assignednew

comment:8 by diaxoaine, 12 days ago

Owner: set to diaxoaine
Status: newassigned

comment:9 by diaxoaine, 10 days ago

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