# For loop break

**URL:** <https://community.hubspot.com/t/for-loop-break/393>\
**Category:** CMS Development\
**Created:** [November 3, 2016, 7:05pm UTC](https://community.hubspot.com/t/for-loop-break/393 "2016-11-03T19:05:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jideokus](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jideokus/32/99730_2.png) [@jideokus](https://community.hubspot.com/u/jideokus)\
**Post date:** [November 3, 2016, 7:05pm UTC](https://community.hubspot.com/t/for-loop-break/393/1 "2016-11-03T19:05:07Z")

</div>

Hi

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

---

<div class="post-metadata">

**Author:** ![Gonzalo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gonzalo/32/106671_2.png) [@Gonzalo](https://community.hubspot.com/u/Gonzalo)\
**Post date:** [November 3, 2016, 7:22pm UTC](https://community.hubspot.com/t/for-loop-break/393/2 "2016-11-03T19:22:14Z")

</div>

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 %}`

---

<div class="post-metadata">

**Author:** ![jideokus](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jideokus/32/99730_2.png) [@jideokus](https://community.hubspot.com/u/jideokus)\
**Post date:** [November 7, 2016, 3:55pm UTC](https://community.hubspot.com/t/for-loop-break/393/3 "2016-11-07T15:55:49Z")

</div>

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.
