Whitespace trim examples
Whitespace trim examples
Section titled “Whitespace trim examples”-
Adding a hyphen in your tag syntax {% raw %}
{{-,-}},{%-and-%}{% endraw %} strips whitespace from the left or right side of a rendered tag.Example below shows the value
tomatohas a space before and after the word when assigned tomy_variable. Adding a hyphen in the tags when displayingmy_variableremoves the spaces:
{% raw %}
{% assign my_variable = " tomato " %}
{{- my_variable -}}{% endraw %}