creative designer

Running a millions of loops within Shopify (or really any platform) is rarely a good idea but there's times that I like adding a code with a loop with a single iteration. This means it's not really looping at all, but it comes with a nice little bonus.

The bonus is quite simply the ability to use the {% break %} tag. This helps me avoid having to wrap things in next if/else statements and just cancel processing any further code within that loop.

{% for i in (1..1) %}
{% assign test = product | default:false %}
{% if test == false %}{% break %}{% endif %}
Test is True!
{% endfor %}

I'm not sure if this offer a performance benefit or not (I'm going to boldly say yes here with zero testing), but for the sort of code I've written it makes things cleaner.

Like to work with me?

Let's talk