Code

Opened 7 years ago

Closed 5 years ago

Last modified 5 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: UI/UX:

Description (last modified by russellm)

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@… 7 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by adrian

  • Component changed from Core framework to Template system
  • Summary changed from [Patch]Extend enclose tag process to Extend enclose tag process

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

Changed 7 years ago by limodou@…

comment:2 Changed 7 years ago by limodou@…

  • Summary changed from Extend enclose tag process to [patch]Extend enclose tag process

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

comment:3 Changed 7 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: http://code.djangoproject.com/ticket/3100

comment:4 Changed 7 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 7 years ago by Simon G. <dev@…>

  • Needs documentation set
  • Needs tests set
  • Summary changed from [patch]Extend enclose tag process to [patch] Extend enclose tag process
  • Triage Stage changed from Unreviewed to Design decision needed

comment:9 Changed 7 years ago by ubernostrum

  • Resolution set to worksforme
  • Status changed from new to closed

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

comment:10 Changed 5 years ago by anonymous

  • Needs tests unset
  • Resolution worksforme deleted
  • Status changed from closed to reopened

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 Changed 5 years ago by Alex

  • Resolution set to invalid
  • Status changed from reopened to closed

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 5 years ago by russellm

  • Description modified (diff)
  • Summary changed from [patch] Extend enclose tag process to Support 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.