Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

shopify

liquid

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

like image 327
quyetdc Avatar asked Mar 04 '23 11:03

quyetdc


1 Answers

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.

like image 162
drip Avatar answered Mar 23 '23 23:03

drip