为什么我无法在if标签中嵌套一个块标签? [英] Why can't I nest a block tag inside an if tag?

查看:141
本文介绍了为什么我无法在if标签中嵌套一个块标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 base.html 的主模板文件,其中有以下代码:

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 %}

问题是,样式表I链接永远不会被应用,

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.

推荐答案

这个问题不再是相关的 - 截至 r12655 ,您可以嵌套一个块标记一个条件。

This question is no longer relevant - as of r12655 you can nest a block tag within a conditional.

这篇关于为什么我无法在if标签中嵌套一个块标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆