Shopify Liquid中的空白控件 [英] Whitespace control in Shopify Liquid

查看:54
本文介绍了Shopify Liquid中的空白控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Shopify最近向Liquid模板语言添加了空白控件: https://help.shopify.com/themes/liquid/basics/whitespace

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

实际上,您可以在标签语法{{- -}}{%- -%}中添加连字符,以去除标签输出的空格(html空行).例如:

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 }}

渲染器:

hello

代替:

 
hello

是否有办法为所有assign标签启用此功能?和/或所有特定的控制流或迭代标签?

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

推荐答案

的确.您在键入Liquid时将其打开.让您的手指来讲话!

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

如果在文本编辑器中加载主题,则可以使用通用的查找全部"命令来查找assign的所有实例.使用该值将周围的{%%}替换为{%--%}.几乎所有的一切.重复您喜欢的任何关键字.

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.

这篇关于Shopify Liquid中的空白控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆