Skip to main content

capture

Creates a new variable with a string value.

You can create complex strings with Liquid logic and variables.

Syntax

{% capture variable %}
value
{% endcapture %}
variable

The name of the variable being created.

value

The value you want to assign to the variable.

{%- assign up_title = product.title | upcase -%}
{%- assign down_title = product.title | downcase -%}
{%- assign show_up_title = true -%}

{%- capture title -%}
{% if show_up_title -%}
Upcase title: {{ up_title }}
{%- else -%}
Downcase title: {{ down_title }}
{%- endif %}
{%- endcapture %}

{{ title }}

Output

Upcase title: HEALTH POTION
Was this page helpful?