Opened 17 years ago
Closed 11 years ago
#6544 closed Bug (wontfix)
Regression with new templates extends checks
Reported by: | Owned by: | ||
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | FunkyBob | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
SVN r7084 breaks existing templates when a comment node is the first element in a template. So templates of the form
{% comment %}bla{% endcomment %} {% extends ... %}
will throw a syntax error with the new behaviour. I suggest allowing comments before the extends tag.
Attachments (1)
Change History (14)
comment:1 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 17 years ago
Has patch: | set |
---|
Here is a patch that allows any number of whitespace or comments before an {% extends %} node. This is more convenient than having to edit all templates (which can be a sufficiently large number).
I'll leave the ticket as closed, but other users might be interested in the patch, so here goes. Note that I did not bother to included tests or documentation since this idea is already rejected.
by , 17 years ago
Attachment: | django-allow-comments-before-extends.diff added |
---|
comment:3 by , 17 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Triage Stage: | Unreviewed → Accepted |
It's reasonable to allow comment template tags, since we allow the {#...#}
form. However, I don't like the patch. It looks like it should be just a simple change to extend_nodelist
in the current code (which admittedly has been modified since the patch was created).
I'll get around to fixing it next time I'm working on trunk.
comment:4 by , 17 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | set |
Status: | reopened → new |
comment:5 by , 17 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Ah, thanks for accepting this. And yes, the patch needs definitely improvement (I am not very familiar with the template API), and unit tests, and documentation updates.
comment:6 by , 16 years ago
Owner: | removed |
---|
Reassigning back to the pool in case somebody wants to work up a better patch in one of the sprints.
comment:7 by , 14 years ago
Type: | → Bug |
---|
comment:8 by , 14 years ago
Severity: | → Normal |
---|
comment:11 by , 11 years ago
Given that nothing outside of a {% block %} is rendered in a template that {% extends %} ... why even wrap your comments in a comment tag?
The template engine allows text nodes to precede the {% extends %} node, so why not just write your comments there, unadorned?
comment:12 by , 11 years ago
Cc: | added |
---|
comment:13 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Clearly nobody has strong feelings about this any more.
Also, there are two simple solutions:
- move your comment below the extends tag
- don't wrap your comment in a tag.
The documentation states, and has stated since before this change, that "If you use {% extends %} in a template, it must be the first template tag in that template." If use of other tags before
{% extends %}
worked before, it shouldn't have, and if it doesn't now that's the way it ought to be.