Passing a data from a section to other section

hi guys ,I wanna pass the data or a variable from a section to other section and also a section to other template.iam a complete beginner in liquid and I want your help.

1 Like

Hello @samir-p-m

Step 1: Set the variable in one section or template.

{% assign var= "text add here....." %}

Step 2: Capture the content if needed.

{% capture var2%}
This is a sample text that I want to pass to Section.
{% endcapture %}

Step 3: Include the other section or template and pass the variables.

{% include 'section' with var1 %}
{% include 'section' with var2 %}
1 Like

what is the case when we pass a variable from snippet to section

Hello @samir-p-m

1.The variable in the snippet using {% assign %} or any other method.
Example snippet named “my_snippet.liquid”:

{% assign var1 = "The snippet variable" %}

2.Include the snippet in the desired section using {% include %} and pass the variable using the with parameter.
Example section named “my_section.liquid”:

{% include 'my_snippet' with var1 %}

3.Now, in “my_section.liquid,” you can access the variable snippet_variable passed from the snippet.
Example usage in “my_section.liquid”:


{{ var1 }}

2 Likes