CMS Development

jideokus
参加者

For loop break

解決

Hi

 

I'm trying to break a for loop to stop the execution of a loop; is this possible with hubl?

0 いいね!
1件の承認済みベストアンサー
Gonzalo
解決策
トップ投稿者 | Diamond Partner
トップ投稿者 | Diamond Partner

For loop break

解決

Nope. But you can set a conditional inside the loop to ignore the next iterations like:

 

  • Ignore if +4 iterations
  • {% for var in vars %}
    {% if loop.index <= 4 %}
    do whatever
    {% endif %}
    {% endfor %}
  •  If an attribute inside the var is different of a filter.
  • {% for var in vars %}
    {% if var.attribute == "filter" %}
    do whatever
    {% endif %}
    {% endfor %}

 

 

If this answer helps you to solve your questions please mark it as a solution.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting

元の投稿で解決策を見る

2件の返信
Gonzalo
解決策
トップ投稿者 | Diamond Partner
トップ投稿者 | Diamond Partner

For loop break

解決

Nope. But you can set a conditional inside the loop to ignore the next iterations like:

 

  • Ignore if +4 iterations
  • {% for var in vars %}
    {% if loop.index <= 4 %}
    do whatever
    {% endif %}
    {% endfor %}
  •  If an attribute inside the var is different of a filter.
  • {% for var in vars %}
    {% if var.attribute == "filter" %}
    do whatever
    {% endif %}
    {% endfor %}

 

 

If this answer helps you to solve your questions please mark it as a solution.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting
jideokus
参加者

For loop break

解決

Thanks for your response @Gonzalo. Great workaround. That's what I used. I was hoping for a way to break it without having to go through the entire loop and run the condition but will have to go with this approach till a break is introduced.

0 いいね!