* stage: Design decision needed => Accepted
Comment:
I don't know what the "capture" tag discussed 3 years ago was, but AFAIK
it didn't come into existence.
This feature can be useful and it's still quite restricted -- it isn't a
general switch statement.
--
Ticket URL: <https://code.djangoproject.com/ticket/12199#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by mark0978@…):
There is another instance where the AS keyword would be very useful
Trying to write a template to include something for xyz: in json, but i
can't put {% firstof %} output thru escapejs as it currently stands.
{{{
xyz: '{% firstof a b %}',
}}}
with AS, we could do:
{{{
{% firstof a b AS c %}
xyz: '{{ c|escapejs }}',
}}}
Right now to do this you end up with a logic block in the template.
{{{
{% if a %}{{ a|escapejs }}{% else %}{{ b|escapejs }}{% endif %}
}}}
which isn't horrible until you only want a or b if EITHER of them is
defined and then it looks like:
{{{
{% if a or b %}xyz: '{% if a %}{{ a|escapejs }}{% else %}{{ b|escapejs
}}{% endif %}',{% endif %}
}}}
while it could be as simple as:
{{{
{% firstof a b AS c %}{% if c %}xyz: '{{ c|escapejs }}',{% endif %}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/12199#comment:8>
* owner: nobody => craigls
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/12199#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"75bc5bc634e90d5ccd2d7fc324df878dc5d4ce5d" 75bc5bc6]:
{{{
#!CommitTicketReference repository=""
revision="75bc5bc634e90d5ccd2d7fc324df878dc5d4ce5d"
Fixed #12199 -- Added the ability to use "as" with the firstof template
tag.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/12199#comment:10>