Acorman
Acorman

Reputation: 91

How do I use a liquid tag inside a conditional statement

I've tried:

{% assign color = {{module_url param='color' -%}} -%}

{% if color == 'red' -%}

Red is the color

{% endif -%}

and lots of variations but without success.

Upvotes: 1

Views: 336

Answers (1)

johnnyd23
johnnyd23

Reputation: 1705

You could capture the color variable first, instead of using assign, and then check against that:

{% capture color -%}
    {{ module_url param='color' }}
{% endcapture -%}

{% if color == 'red' -%}

Red is the color

{% endif -%}

Upvotes: 1

Related Questions