Opened 17 years ago

Closed 11 years ago

#6544 closed Bug (wontfix)

Regression with new templates extends checks

Reported by: Bastian Kleineidam <calvin@…> 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)

django-allow-comments-before-extends.diff (1.8 KB ) - added by Bastian Kleineidam <calvin@…> 17 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by James Bennett, 17 years ago

Resolution: invalid
Status: newclosed

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.

comment:2 by Bastian Kleineidam <calvin@…>, 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 Bastian Kleineidam <calvin@…>, 17 years ago

comment:3 by Malcolm Tredinnick, 17 years ago

Resolution: invalid
Status: closedreopened
Triage Stage: UnreviewedAccepted

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 Malcolm Tredinnick, 17 years ago

Owner: changed from nobody to Malcolm Tredinnick
Patch needs improvement: set
Status: reopenednew

comment:5 by Bastian Kleineidam <calvin@…>, 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 Malcolm Tredinnick, 16 years ago

Owner: Malcolm Tredinnick removed

Reassigning back to the pool in case somebody wants to work up a better patch in one of the sprints.

comment:7 by Julien Phalip, 14 years ago

Type: Bug

comment:8 by Julien Phalip, 13 years ago

Severity: Normal

comment:9 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:10 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:11 by FunkyBob, 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 FunkyBob, 11 years ago

Cc: FunkyBob added

comment:13 by FunkyBob, 11 years ago

Resolution: wontfix
Status: newclosed

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.
Note: See TracTickets for help on using tickets.
Back to Top