Whitespace control
In Liquid, you can include a hyphen in your tag syntax {{-
, -}}
, {%-
, and -%}
to strip whitespace from the left or right side of a rendered tag.
Normally, even if it doesn't output text, any line of Liquid in your template will still output an empty line in your rendered HTML:
Notice that there are two empty lines in the rendered template:
By including hyphens in your Liquid tag, ({%-
and -%}
), you can strip the generated whitespace from the rendered template:
If you need to control the whitespace on only one side of the Liquid tag, you can include the hyphen on just the opening or closing tag. In the example below, a hyphen is on the closing Liquid tag around customer.name
.