Shopify — How to pass variables to snippet

This is just a small snippet I noted while I was working on a Shopify theme project for my client.

Method 1: Declare variables right above your snipet:

{% assign snippet_variable = ‘this is it’ %}
{% assign snippet_variable_two = ‘this is also it’ %}
{% include ‘snippet’ %}

Method 2: Include variable into include command:

{% include ‘snippet’, snippet_variable: ‘this is it’, snippet_variable_two: ‘this is also it’ %}

I hope this will be useful : )

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.