How do I break out of loop in Liquid, mainly a for-loop? I've tried {% break %}, but that fails with There were errors saving your file: Unknown tag 'break'.
{% break %}
I'm trying to achieve something like:
var variants = []; {% for item in cart.items %} {% if item.product.handle == "handle-name" %} variants = {{item.product.variants | json}}; {% break %} // won't work {% endif %} {% endfor %}
For future visitors. Above code does work in current Liquid (gem v2.5.1).
2.1m questions
2.1m answers
60 comments
57.0k users