Is there a “break” tag to escape a loop in Liquid?
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' . 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). 来源: https://stackoverflow.com/questions/8028229/is-there-a-break-tag-to-escape-a-loop-in-liquid