0
这个例子在http://djangosnippets.org/snippets/2421/原样。使用Django沿着模板传递它的活动菜单
模板放在/包括/ tabs.html
<ul class="tab-menu">
<li class="{% if active_tab == 'tab1' %} active{% endif %}"><a href="#">Tab 1</a></li>
<li class="{% if active_tab == 'tab2' %} active{% endif %}"><a href="#">Tab 2</a></li>
<li class="{% if active_tab == 'tab3' %} active{% endif %}"><a href="#">Tab 3</a></li>
</ul>
在page.html中的模板放在
{% include "includes/tabs.html" with active_tab='tab1' %}
的变量被沿着从页面模板传递给tabs.html 。
你将如何从通有源标签变量:
- page.html (pass active tab1)
- extends base.html
- includes tabs.html (how to get it here.)