Jinja2 语法

Jinja2模板引擎相关语法
1.变量取值:{{}}
2.控制语句:
2.1if语句:

{% if condition %}
    <p>Condition is True</p>
{% endif %}

2.2for循环语句:

{% for item in items %}
    <p>{{ item }}</p>
{% endfor %}

3.过滤器:使用|符号表示过滤器:

<p>{{ name|capitalize }}</p>

4.继承:使用{% extends %}表示继承

{% extends "base.html" %}
{% block content %}
    <p>This is the content of the child template.</p>
{% endblock %}

5.包含:使用{% include %}表示包含其他模板

{% include "header.html" %}
<p>This is the content of the main template.</p>
{% include "footer.html" %}

6.注释:使用{# #}表示注释:

{# This is a comment. #}

你可能感兴趣的:(python,bash)