Opened 12 years ago

Closed 10 years ago

Last modified 10 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@… 12 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 12 years ago by Adrian Holovaty

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?

Changed 12 years ago by limodou@…

Attachment: template.patch added

comment:2 Changed 12 years ago by limodou@…

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

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

comment:3 Changed 12 years ago by Eric Van Dewoestine <ervandew@…>

I added a similar patch before stumbling on this ticket.

I took the liberty of marking mine as a duplicate:

comment:4 Changed 12 years ago by limodou

Hi, Eric:

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

comment:5 Changed 12 years ago by Simon G. <dev@…>

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

comment:9 Changed 12 years ago by James Bennett

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 Changed 10 years ago by anonymous

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'. 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 Changed 10 years ago by Alex Gaynor

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 Changed 10 years ago by Russell Keith-Magee

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