Hello,
That’s a rather specialized behavior for the general purpose {% block %} tag.
I’m not convinced that building in such specialized behavior beats composing
blocks i.e. handling the condition with a {% if %} tag.
The Django template language has way too much ad-hoc, inconsistent syntax in
its built-in tags. I don’t like the idea of adding more.
We have to balance saving keystrokes against increasing the amount of things
every Django user needs to know. In this regard, adding that new syntax looks
like a bad tradeoff to me.
--
Aymeric.
> On 30 janv. 2015, at 19:46, Markus Amalthea Magnuson
> <[email protected]> wrote:
>
> Hey all,
>
> Tim Graham suggested I posted to this list regarding an idea for a new
> feature: conditional block tags.
>
> I've summarized the feature in this ticket:
> https://code.djangoproject.com/ticket/24232
>
> The basic idea is to be able to write something like this in a template:
>
> {% block myblock if myvariable %}my content{% endblock %}
>
> If the condition is false it is as if the block wasn't there, meaning its
> parent would be rendered instead, if it exists.
>
> This is really a short form of:
>
> {% if myvariable %}
> my content
> {% else %}
> {{ block.super }}
> {% endif %}
>
> Note that it may seem similar to ticket #9173 but they are different, which I
> try to make clear in this comment:
> https://code.djangoproject.com/ticket/24232#comment:2
>
> So, what do you think?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/django-developers
> <http://groups.google.com/group/django-developers>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/9ce259ff-6a2e-493a-a6df-1c15b43fe9c0%40googlegroups.com
>
> <https://groups.google.com/d/msgid/django-developers/9ce259ff-6a2e-493a-a6df-1c15b43fe9c0%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/E5734A77-AE8F-4F70-BA87-97F2D77D5488%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.