Opened 19 years ago

Closed 18 years ago

Last modified 17 years ago

#1147 closed defect (wontfix)

[patch] Tags cannot contain newlines

Reported by: jim-django@… Owned by: Adrian Holovaty
Component: Template system Version:
Severity: normal Keywords:
Cc: nslater@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

>>> t1 = Template("""It is the {% now "jS of F" %}""")
>>> t2 = Template("""It is the {% now
... "jS of F" %}""")
>>> t1.render(Context())
'It is the 31st o2:27 December'
>>> t2.render(Context())
'It is the {% now\n"jS of F" %}'

(Note also that the {% now %} I've taken from it's own documentation is a bit broken)

Attachments (2)

patch.diff (810 bytes ) - added by jim-django@… 19 years ago.
Patch to allow newlines inside tags
patch.2.diff (1.0 KB ) - added by jim-django@… 19 years ago.
Patch to allow newlines inside tags (corrected)

Download all attachments as: .zip

Change History (13)

by jim-django@…, 19 years ago

Attachment: patch.diff added

Patch to allow newlines inside tags

by jim-django@…, 19 years ago

Attachment: patch.2.diff added

Patch to allow newlines inside tags (corrected)

comment:1 by anonymous, 19 years ago

Summary: Tags cannot contain newlines[patch] Tags cannot contain newlines

comment:2 by Adrian Holovaty, 19 years ago

Resolution: wontfix
Status: newclosed

I don't see a reason why tags should include newlines. Marking as a wontfix.

comment:3 by Noah Slater <nslater@…>, 18 years ago

Cc: nslater@… added
Resolution: wontfix
Status: closedreopened

Adrian, can you provide more of an argument other than your personal opinion? There are many instances where I have very long tags or nested tags and this forces me to have lines that wrap 2,3 sometimes 4 times on a 80 character width display.

comment:4 by Noah Slater <nslater@…>, 18 years ago

Here is an example of an occasion where I would like to be able to use newlines:

<a href="{{ related_object.uri }}keywords/" title="{% if related_object.get_profile %}All {% ifequal user related_object %}your{% else %}{{ related_object.get_profile.name_possessive }}{% endifequal %} {{ related_object.verbose_name }} {% if contacts %}contacts {% endif%}favorite keywords{% else %}All keywords for this {{ related_object.verbose_name }}{% endif %}">...</a>

comment:5 by Malcolm Tredinnick, 18 years ago

Resolution: wontfix
Status: reopenedclosed

You cannot wrap inside a tag, but there is nothing to stop you wrapping between tags. So the above line can be broken at any number of points. Right after any %}, for example.

comment:6 by Noah Slater <nslater@…>, 18 years ago

Resolution: wontfix
Status: closedreopened

No, you are mistaken.

If you take a look at my example again you will see that the template tags occur in an element's attribute value, I.E. between quote characters and hence cannot contain newlines.

comment:7 by anonymous, 18 years ago

Resolution: wontfix
Status: reopenedclosed

Newlines are permitted inside attribute values both in SGML and XML.

Please refrain from reopening this ticket. If you have a genuine case that does not work, post it to django-users list and somebody there can help you to get it to work.

comment:8 by Malcolm Tredinnick, 18 years ago

(Last comment was by me.)

comment:9 by anonymous, 18 years ago

If the value is the value attribute of a hidden form element, you've just ensured that it will be posted with an embedded newline. If this is a session id or similar, chances are it won't match an existing session, and will be rejected.

And sure, this could be fixed in the view by stripping newlines/ other white space (although this is not without its problems), but the justification for not allowing tags to contain newlines seems arbitrary at best.

comment:10 by anonymous, 18 years ago

Agreed, just because newlines are permitted does not mean that is desirable.

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