Opened 18 years ago

Closed 15 years ago

Last modified 15 years ago

#3090 closed enhancement (invalid)

Support for arguments on intermediate tag tokens (ex. {% if arg %}{% elif arg %}{% endif %})

Reported by: limodou@… Owned by: nobody
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Russell Keith-Magee)

Currently the template functionality prevents creation of tags which have intermediate tags requiring arguments.

For instance:

{% myif arg %}
  first block
{% elif arg %}  <-- current version would fail to parse this correctly because of the arg
  second block
{% endmyif %}

The attached patch removes this restriction.

Attachments (1)

template.patch (1.4 KB ) - added by limodou@… 18 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Adrian Holovaty, 18 years ago

Component: Core frameworkTemplate system
Summary: [Patch]Extend enclose tag processExtend enclose tag process

I don't see a patch here...Maybe you forgot to upload it?

by limodou@…, 18 years ago

Attachment: template.patch added

comment:2 by limodou@…, 18 years ago

Summary: Extend enclose tag process[patch]Extend enclose tag process

I added the patch. I'm sorry forgot that.

comment:3 by Eric Van Dewoestine <ervandew@…>, 18 years ago

I added a similar patch before stumbling on this ticket.

I took the liberty of marking mine as a duplicate: http://code.djangoproject.com/ticket/3100

comment:4 by limodou, 18 years ago

Hi, Eric:

I checked your patch, it's very similar with mine. And I hope the patch can be accepted.

comment:5 by Simon G. <dev@…>, 18 years ago

Needs documentation: set
Needs tests: set
Summary: [patch]Extend enclose tag process[patch] Extend enclose tag process
Triage Stage: UnreviewedDesign decision needed

comment:9 by James Bennett, 17 years ago

Resolution: worksforme
Status: newclosed

The tag presented in this snippet at djangosnippets seems to show that what you want is possible. Closing "worksforme".

comment:10 by anonymous, 15 years ago

Needs tests: unset
Resolution: worksforme
Status: closedreopened

I would like to see this change. The snippet mentioned uses multiple templatetags, and would need more to support 'default' or 'else'. http://www.djangosnippets.org/snippets/967/ shows a way to achieve this, but it's a hack that would be unnecessary with this patch.

Since the patch is so simple - it's clear by inspection that the reordering can't break anything (unless someone attempts to 'parse_until' an empty block tag) - I would really like to see its inclusion.

comment:11 by Alex Gaynor, 15 years ago

Resolution: invalid
Status: reopenedclosed

This ticket was closed by a core developer. If you disagree with the decision please use the django-developers mailing to discuss this

comment:12 by Russell Keith-Magee, 15 years ago

Description: modified (diff)
Summary: [patch] Extend enclose tag processSupport for arguments on intermediate tag tokens (ex. {% if arg %}{% elif arg %}{% endif %})

Following discussion on django-developers, it looks like this ticket may have been closed in error - the snippet may solve the same problem (elseif/case), but doesn't address the core issue of the ticket. The description on #3100, which was closed as a duplicate of this ticket, is much more enlightening as to the actual problem. To that end, I've reopened #3100.

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