include标签_flask

页面上共性的代码,比如顶部和底部,都可以抽离到comment,再通过include引用过来

如果想使用父级模板的时候,跟 macro 不一样,直接使用就可以

引用的路径,跟“import”一样,也得从“template”绝对路径引用

示例代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    {% include 'common/header.html' %}
    <div class="content">
        这里是中间的
    </div>
    {% include 'common/footer.html' %}
</body>
</html>
<style>
    .nav ul{
        overflow:hidden;
    }
    .nav ul li{
        float:left;
        margin: 0 20px;
    }
</style>


<nav class="nav">
    <ul>
        <li>首页</li>
        <li>课程详情</li>
        <li>视频教程</li>
        <li>关于我们</li>
    </ul>
</nav>

猜你喜欢

转载自blog.csdn.net/hebi123s/article/details/81983278
今日推荐