我在include中插入了一个块,希望我可以引用该块并在需要时添加额外的链接。
site_page.html:
{% extends 'home/sbadmin_base.html' %}
{% load extras %}
{% load static %}
{% block content %}
{% include 'sites/site_tabs.html' %}
{% block extratabs %}
<li {{ active_sims|safe }}>
<a href="{% url 'sites:site_overview' SiteID %}">Edit Site</a>
</li>
{% endblock %}
site_tabs.html
{% load extras %}
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li {{ active_ip|safe }}><a href="{% url 'sites:site_overview' SiteID %}">Overview</a>
</li>
<li {{ active_files|safe }}><a href="{% url 'sites:site_detail_files' SiteID %}">Files and Photos</a>
</li>
{% block extratabs %}
{% endblock %}
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane fade in active" id="ip">
<div class="row">
当我的页面被渲染时,“extratabs”只会出现在包含之下和列表之外,如下所示:
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="/sites/site/7">Overview</a>
</li>
<li ><a href="/sites/site/files/7">Files and Photos</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane fade in active" id="ip">
<div class="row">
<li >
<a href="/sites/site/7">Edit Site</a>
</li>