Reputation: 91595
I have a master template file called base.html
, in it I have the following code:
{% ifequal environment "dev" %}
{% block stylesheets %}{% endblock %}
{% endifequal %}
I inherit this in other templates and do the following:
{% block stylesheets %}
<link ... >
{% endblock %}
The problem is, the stylesheet I link never gets applied, the stylesheets block seems to be ignored whether the ifequal condition is met in the base or not.
Upvotes: 7
Views: 6556
Reputation: 126631
This question is no longer relevant - as of r12655 you can nest a block tag within a conditional.
Upvotes: 6
Reputation: 99811
The original question title is no longer true, according to this comment on a ticket on Django.
I'm not sure why not, but you could just do:
{% block stylesheets %}
{% ifequal environment "dev" %}
... something ....
{% else %}
{{ block.super }}
{% endifequal %}
{% endblock %}
Having rethought this a bit - I guess that means repeating that logic inside each of your templates, which is fairly unsatisfactory, but I'll leave this answer here anyway. I've had a quick look through the Django tickets and can't find anything relevant.
Upvotes: 18