Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through capture
are strings.
Input
{% capture my_variable %}I am being captured.{% endcapture %} |
Output
I am being captured. |
Using capture
, you can create complex strings using other variables created with assign
:
Input
{% assign favorite_food = "pizza" %} |
Output
I am 35 and my favourite food is pizza. |