Reputation: 1
I've written the following code
{% case NAME %}
{% when "abc" %}
{% assign varOne = "123" %}
{% assign varTwo = "345" %}
{% when "bac" %}
{% assign varOne = "321" %}
{% assign varTwo = "543" %}
{% endcase %}
<p>{{ varOne }}</p>
<p>{{ varTwo }}</p>
i wanted to know if shopify allows me to set values like this inside a conditional block in shopify liquid and use them outside the conditional block? are there any scope related implications for the same?
Upvotes: 0
Views: 1927
Reputation: 123
Shopify allow to use {% assign %} method inside conditional {% case %} statements.
{% assign food = 'cake' %}
{% case food %}
{% when 'cake' %}
{% assign isTasty = 'true' %}
{% when 'carrot' %}
{% assign isTasty = 'false' %}
{% endcase %}
{{ isTasty }}
This will return 'true'
Upvotes: 1