#1147 closed defect (wontfix)
[patch] Tags cannot contain newlines
Reported by: | 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)
Change History (13)
by , 19 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 19 years ago
Summary: | Tags cannot contain newlines → [patch] Tags cannot contain newlines |
---|
comment:2 by , 19 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I don't see a reason why tags should include newlines. Marking as a wontfix.
comment:3 by , 18 years ago
Cc: | added |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
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 , 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 , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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 , 18 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
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 , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
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:9 by , 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 , 18 years ago
Agreed, just because newlines are permitted does not mean that is desirable.
Patch to allow newlines inside tags