简体   繁体   English

Shopify Liquid中的空白控件

[英]Whitespace control in Shopify Liquid

Shopify recently added whitespace control to the Liquid templating language: https://help.shopify.com/themes/liquid/basics/whitespace Shopify最近在Liquid模板语言中添加了空白控件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. 您实际上在标记语法{{- -}}{%- -%}添加了一个连字符,以删除标记输出的空白(html空行)。 For example: 例如:

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

Renders: 呈现:

hello

Instead of: 代替:

 
hello

Is there a way to turns this on for all assign tags? 有没有办法为所有assign标签启用此功能? and/or all specific control flow or iteration tags? 和/或所有特定的控制流程或迭代标签?

Indeed. 确实。 You turn it on when you type your Liquid. 键入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. 如果在文本编辑器中加载主题,则可以使用常见的“查找全部”命令查找所有assign的实例。 Use that to replace the surrounding {% %} with {%- -%}. 用它来用{% - - %}替换周围的{%}。 Pretty much all there is to it. 几乎所有的东西都有它。 Repeat for any keywords you like. 重复您喜欢的任何关键字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM