mardi 19 mai 2015

In django, can I use 'as' in if tags like so: {% if excessively_verbose.chain_of_long.nested_references as foo%}

I'm populating xml from json with an excessively_verbose.chain_of_long.nested_references.

Sometimes that parent level isn't there, and in an effort to reduce the padding of my template, I'd like to use something a little like this:

{% if excessively_verbose.chain_of_long.nested_references as foo%}

I've tried the above and the below:

{% if excessively_verbose.chain_of_long.nested_references with excessively_verbose.chain_of_long.nested_references as foo%}

But I'm getting unused with/as at end of is.

Is this possible (preferable without re-writing the {% if %} tag)? It seems simple, straightforward and useful (to me at least)!

I guess this is the Django equivalent of this, which does not look promising

Aucun commentaire:

Enregistrer un commentaire