Variable tags

Variable tags are used to create new Liquid variables.

assign

Creates a new variable. Assignments can also use filters to modify the value.

Code

{% assign is_valid = true %}

{% if is_valid %}

It is valid.

{% endif %}

{% assign name = dave bowman' | upcase %}

{{ name }}

Output

It is valid.

DAVE BOWMAN

capture

Captures the content within its block and assigns it to a variable. This content can then be rendered later by using output tags.

Code

{% capture hello %}Hello, {{ user.fullname }}.{% endcapture %}

{{ hello }}

{{ hello }}

Output

Hello, DAVE BOWMAN.

Hello, DAVE BOWMAN.

See also