quyetdc
quyetdc

Reputation: 1585

Shopify liquid: differences between {% %} and {%- -%}

Can anyone help me distinguish {% %} and {%- -%}. What're the differences between those syntax. In all of my usages, I can use any of theme

Upvotes: 5

Views: 2341

Answers (1)

drip
drip

Reputation: 12933

The only difference is that one strips the white space and the other doesn't.

So this {% %} will keep any white space around it.

And this {%- -%} will strip the white space.

The same applies for {{ }} and {{- -}}.

Or to keep it even more simple {{- -}} is the same as {{ }} but with the strip filter applied to it so it becomes {{ | strip }}.

You can consider it as a shorthand method for stripping the content.

Upvotes: 10

Related Questions