You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many years, our team has used this pattern when we don't want code to render if a specific parameter is blank:
{%- liquid
assign product_object = product_object | default: closest.product
if product_object == blank
break
endif
...code for if product_object is not blank...
-%}
We've recently started using AI for our code reviews, and it consistently flags this use of "break", pointing out that it's only meant to be used within a "for" loop. In practice, it works perfectly outside a loop, but we're now wondering whether this might stop working in the future, leaving us with a lot of code to update all at once.
We're also quite attached to this approach: using "break" this way means we avoid wrapping all our code in an "if" statement, which keeps things looking cleaner.
So our question is: what's the outlook for this use of "break"? Will it continue to be working the way we're using it, or is it likely to stop working at some point? We'd love to hear from anyone who can shed some light on this. Thank you!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
For many years, our team has used this pattern when we don't want code to render if a specific parameter is blank:
We've recently started using AI for our code reviews, and it consistently flags this use of "break", pointing out that it's only meant to be used within a "for" loop. In practice, it works perfectly outside a loop, but we're now wondering whether this might stop working in the future, leaving us with a lot of code to update all at once.
We're also quite attached to this approach: using "break" this way means we avoid wrapping all our code in an "if" statement, which keeps things looking cleaner.
So our question is: what's the outlook for this use of "break"? Will it continue to be working the way we're using it, or is it likely to stop working at some point? We'd love to hear from anyone who can shed some light on this. Thank you!
All reactions