Liquid - switch statement with a variable -
i have following situation:
<label for="swatch-{{ option_index }}-{{ value | handle }}" style="background-color: {% capture color %} {{ value | handle }} {% endcapture %} {% assign handle = color %} {% case handle %} {% when 'red' %} red; {% when 'navy' %} navy; {% else %} #f00; {% endcase %} background-image: url({{ value | handle | append: '.' | append: file_extension | file_url }})">
when {{color}} prints right color, when try use in comparison statement fails, returns blank (or rather default #f00
. same if statement.
if define
{% assign handle = 'red' %}
then works fine.
have tried using {{ value | handleize }}
? far i'm aware "handle" not right operator.
Comments
Post a Comment