Manas Man Singh
Manas Man Singh

Reputation: 25

Looping in jinja

I have a Integer value inside {{ review.rating }} . Now I want to loop using jinja , the number of times the value of review.rating.

Eg. if I have review.rating = 4 , I want to display <div>A</div> , 4 times.

How can I do so?

Upvotes: 0

Views: 143

Answers (1)

Tamzid Ahmed
Tamzid Ahmed

Reputation: 640

You can use for loop in jinja like this:

{% for i in range(review.rating) %}
<span>{{ i }}</span>
{% endfor %}

Upvotes: 4

Related Questions