capture Tag

Captures the string inside of the opening and closing tags and assigns it to a variable.

Description

Captures the string inside of the opening and closing tags and assigns it to a variable.

{% capture my_variable %}I am being captured.{% endcapture %}

The capture tag is particularly useful when you have a multi-line block of text that you’d like to store in a variable:

      {% capture lyrics %}
        Somebody's Heine<br>
        Is crowdin' my icebox<br>
        Somebody's cold one<br>
        Is givin' me chills<br>
        Guess I'll just close my eyes
      {% endcapture %}
      

Parameters

None.