Skip to main content Link Search Menu Expand Document (external link)

Whitespace trim examples

  • Adding a hyphen in your tag syntax¬† {{- , -}}, {%- and -%} strips whitespace from the left or right side of a rendered tag.

    Example below shows the value tomato has a space before and after the word when assigned to my_variable. Adding a hyphen in the tags when displaying my_variable removes the spaces:

  {% assign my_variable = " tomato " %}

  {{- my_variable -}}