Whitespace control in Shopify Liquid

[亡魂溺海] 提交于 2019-12-23 17:09:11

问题


Shopify recently added whitespace control to the Liquid templating language: https://help.shopify.com/themes/liquid/basics/whitespace

You essentially add an hyphen in your tag syntax {{- -}}, {%- -%} to strip whitespace (html empty line) outputted by a tag. For example:

{%- assign variable = "hello" -%}
{{ variable }}

Renders:

hello

Instead of:

 
hello

Is there a way to turns this on for all assign tags? and/or all specific control flow or iteration tags?


回答1:


Indeed. You turn it on when you type your Liquid. Let your fingers do that talking!

If you load up your theme in a text editor, you can use the common Find All command to find all instances of assign. Use that to replace the surrounding {% %} with {%- -%}. Pretty much all there is to it. Repeat for any keywords you like.



来源:https://stackoverflow.com/questions/39573742/whitespace-control-in-shopify-liquid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!