Hi,

On Tue, Feb 17, 2015 at 9:04 PM, Preston Timmons <[email protected]>
wrote:

> After looking at this, there's nothing special about blocks compared to
> any other node. They could just as well be evaluated at render time.
>
> Here's a branch that implements this change:
>
>
> https://github.com/prestontimmons/django/compare/conditional-blocks?expand=1
>
> Before returning blocks into block_context to be used as overrides, it
> loops through any if nodes and checks the conditions.
>
> The one case that's kinda funny is if you do something like:
>
> {% if var %}
>     {% block content %}...{% endblock %}
> {% else %}
>     {% block content %}...{% endblock %}
> {% endif %}
>
> Currently, the second block node will raise a TemplateSyntaxError because
> it's defined twice. Does that matter?
>

I don't think it does. The construct is useless anyway. The only use case I
could think of is:

{% if var %}
    <div>var specific content</div>
    {% block content %}...{% endblock %}
{% else %}
    {% block content %}...{% endblock %}
{% endif %}

But that could also be created with the block outside the if statement. You
would probably use it in the sense of "only include this block if", or "if
a, block, else block b". Redefining the content block does not seem to make
sense to me in those cases.

Tino

-- 
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/CANQFsQA-ao9ER0ha7DBjYnRS-PmZsh7rOtp9Kj64GEgOpmj7aQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to