我参考了jinja2的循环文档,但没有运气动态生成以下 html。
<li>
<a href="#1"> This is the first sentence</a>
</li>
<li>
<a href="#2">This is the senond sentence</a>
</li>
<li>
<a href="#3">This is the third sentence</a>
</li>
<li>
<a href="#4">This is the fourth sentence</a>
</li>
像这样的东西应该工作:
{% for i in length %}
<li>
<a href="#{{i}}"> This is a sentence </a>
</li>
其中长度每次都在变化,并且已经由后台的 python 脚本预定义!这里长度 = 4。