本文使用的摸本继承用于开发带有导航窗口的网站:
在导航窗文件中需要被替换的地方使用
{% block contentPage %}
需要被替换的内容
{% endblock %}
在非导航页面开头引入父模板路径:
{% extends 'common/navigation/navigation.html' %}
然后使用:
{% block contentage %}
用于替换的内容
{% endblock %}
例如:
这是导航窗口中需要被替换的内容:
{% block contentPage %}
<div>
<div class="row " style="text-align: center;margin-top:4%">
<p style="font-size: 35px;"> 哦吼,页面不见了..... </p>
<p style="font-size: 20px;margin-top:2%">点击看心情随机返回 <a
style="font-size: 18px;font-weight:bold;"> 返回</a></p>
<div style="margin-top:4%">
<div>
<img src="../../../static/picture/404.png">
</div>
<div>
<img src="../../../static/picture/provocative.png">
</div>
</div>
</div>
</div>
{% endblock %}
这是替换导航页面的内容:
{% extends 'common/navigation/navigation.html' %}
{% block contentPage %}
<div class="row" ng-app="homePage" ng-controller="homePageCtl">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>aaaaa:</h5>
<div ibox-tools></div>
</div>
<div class="ibox-content">
{# <input type="text" class="form-control input-sm m-b-xs" id="filter"#}
{# placeholder="Search in table">#}
<table id="planTable" class="footable table table-stripped table-bordered" data-page-size="8">
<thead>
<tr class="text-center">
<th>aa</th>
<th>bb</th>
<th>cc</th>
<th>dd</th>
</tr>
</thead>
<tbody>
<tr class="gradeX" ng-repeat="values in tableValues">
<td>[[ values.a ]]</td>
<td class="center">[[ values.b ]]</td>
<td class="center">[[ values.c ]]</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<ul class="pagination pull-right"></ul>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<script src="static/js/LPMS/homePage.js"></script>
{% endblock %}
继承之前的页面:
成功继承后的页面:
可以看到正常的表格内容替换了那个欠打的404页面。