range in jinja2 inside a for loop

后端 未结 2 977
渐次进展
渐次进展 2021-02-03 18:14

I have a nested list. I need to iterate through a list and keep it in for loop as shown below.

{% for alpha in list %}
    
相关标签:
2条回答
  • 2021-02-03 18:41

    You can use the "length" property:

    {% for n in range(yourList| length) %}
           <p class="someclass">{{n + 1}}.</p>
           <a class="someclass2" 
           href="{{ url_for( 'yourFunction', Int = yourList[n].iterable)}}">
           {{yourList[n].iterable}}</a><br>
    {% endfor %}
    

    Length is similar to len(yourlist) that we have in python.

    0 讨论(0)
  • 2021-02-03 18:47

    It's just like Python:

    {% for n in range(n) %}
        {% for line in check[n][2:] %}
            <p> {{ beta[0][0] }} </p>
        {% endfor %}
    {% endfor %}
    
    0 讨论(0)
提交回复
热议问题