1 模板引入子html--include

7 模板引擎
    - 母版

    - include,导入公共的html
        a. 用法:{% include "pub.html" %}, pub.html还可以添加 {{ name }}
        b. 一个页面可以导入多次,一个html只能有一个母版
        c.样例
            # public.html
                <div class="public">
                    <div class="content">
                        {{ userinfo }}
                    </div>
                </div>

            # app02_test.html
                <h3>include</h3>
                {% include "public.html" %}
                {% include "public.html" %}

            # views
            def test(request):
                return render(request, 'app02_test.html', {'userinfo':{'k1':'v1', 'k2': 'v2'}})
View Code

相关文章:

  • 2021-11-18
  • 2022-01-31
  • 2022-02-01
  • 2021-12-26
  • 2021-08-24
  • 2021-09-28
  • 2021-09-08
  • 2022-12-29
猜你喜欢
  • 2021-10-08
  • 2021-08-16
  • 2021-12-13
  • 2021-11-12
  • 2021-10-15
  • 2021-10-30
  • 2022-01-19
相关资源
相似解决方案