question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When I use **while** not stop in the views

See original GitHub issue

Hello 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:closed
  • Created 4 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
defnullcommented, Jan 3, 2020

Yes, that’s it. This change solves the issue. Hurray \o/

0reactions
kujengacommented, Nov 1, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found