Can't access variable defined in Snippet from Template

daveh0
Tourist
6 0 1

I have a snippet that is included in multiple templates. It performs some operations and then defines a few variables with values based on the results of those operations. The templates then need to use those those values in a couple different ways.

It seems that I cannot access a variables defined in the snippet from the templates. A VERY watered down example:

Sinppets/colors.liquid

 

{% assign myVar = "bar" %}

 

 

Templates/color-picker.liquid

 

{% assign myVar = "foo" %}
{% render 'colors' %}
{{ myVar }}

 

 

The output of this is foo while the expected output is bar.

Am I doing something wrong, or is this just not possible?

0 Likes