When I use **while** not stop in the views
See original GitHub issueHello guys, I’m trying to use the while statement in views, but I don’t stop, even if the condition is met, look this:
<div class="flexslider flexslider-thumb">
<ul class="previews-list slides">
<% qtd_img = 0 %>
% for i in range(1, 11):
% if getattr(produto, 'imagem' + str(i)) is not None:
<li>
<a id="imgthb_{{i}}" href="{{usar_webp(get_imagem('produtos', getattr(produto, 'imagem' + str(i))))}}" class="cloud-zoom-gallery" rel="useZoom: 'zoom1', smallImage: '{{usar_webp(get_imagem('produtos', getattr(produto, 'imagem' + str(i))))}}'">
<img src="{{usar_webp(get_imagem('produtos', getattr(produto, 'imagem' + str(i))))}}" alt="Imagem {{i}}"/>
</a>
</li>
<% qtd_img += 1 %>
% end
% end
{{qtd_img}}
% while qtd_img < 3:
<li>
<a href="{{usar_webp('/static/images/branco400.jpg')}}" class="cloud-zoom-gallery" rel="useZoom: 'zoom1', smallImage: '{{usar_webp('/static/images/branco400.jpg')}}'">
<img src="{{usar_webp(''/static/images/branco400.jpg')}}" alt="Sem imagem"/>
</a>
</li>
<% qtd_img += 1 %>
% end
</ul>
</div>
In this code I try use the while instruction to show in minimal three images for the slide layout. But never stops, anybody know solve this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
While loop does not stop when the condition is met
While loop does not stop when the condition is met · 4. Indent your code properly and people will be more able to...
Read more >Why doesn't my while loop stop? - Quora
Most probably your condition is infinitely true, thus, the while loop doesn't stop until the condition become false.
Read more >Loops: while and for - The Modern JavaScript Tutorial
It doesn't stop the whole loop. Instead, it stops the current iteration and forces the loop to start a new one (if the...
Read more >SQL WHILE loop with simple examples
BREAK statement is used in the SQL WHILE loop in order to exit the current iteration of the loop immediately when certain conditions...
Read more >While...End While Statement - Visual Basic - Microsoft Learn
The While statement always checks the condition before it starts the loop. Looping continues while the condition remains True . If condition is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, that’s it. This change solves the issue. Hurray \o/
Hi @defnull , I’ve submitted this PR to back-port the fix here to the 0.12 branch: https://github.com/bottlepy/bottle/pull/1402