I see both of your points, but I should also mention that a better example
than what I provided is when you want to have a block inside an
if-statement, which is not possible today:
{% if myvariable %}
{% block myblock %}my content{% endblock %}
{% endif %}
That inner block will always be rendered. A conditional version would look
like:
{% block myblock if myvariable %}my content{% endblock %}
Anyway, if there is still consensus that this is not a desirable feature,
feel free to close the ticket at:
https://code.djangoproject.com/ticket/24232
On Sat, Jan 31, 2015 at 2:17 PM, Marc Tamlyn <[email protected]> wrote:
> I personally don't see any problem with the existing syntax and find it
> much easier to understand.
>
> On 31 January 2015 at 12:43, Aymeric Augustin <
> [email protected]> wrote:
>
>> 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].
>> 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/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.
>>
>>
>> --
>> 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
>> <https://groups.google.com/d/msgid/django-developers/E5734A77-AE8F-4F70-BA87-97F2D77D5488%40polytechnique.org?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit 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/CAMwjO1FWL4M8h9yn7E-Oz0AobU%3D3QC%2BZPO9HYGnh24pkTAuYBw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CAMwjO1FWL4M8h9yn7E-Oz0AobU%3D3QC%2BZPO9HYGnh24pkTAuYBw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit 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/CAOXH8SXVZRigtmJVJsz2j2NaQ1yM%2Bc0yCTvVnEJ1JSzt5%3DwL7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.