Shopify:为什么Liquid有时会使用{%-而不是{%? [英] Shopify: Why does Liquid sometimes use {%- instead of {%?
问题描述
我一直在浏览默认主题的代码,并且我注意到有时它们使用{%
标记来指示Liquid代码(根据文档),但是有时它们使用{%-
.
I've been looking through the code of the default theme, and I've noticed that sometimes they use the {%
tag to indicate Liquid code (as per the documentation), but other times they use {%-
.
例如:
{% case section.settings.image_size %}
{% when 'small' %}
{%- assign product_image_width = 'medium-up--one-third' -%}
{%- assign product_description_width = 'medium-up--two-thirds' -%}
我在Liquid文档中找不到{%-
的单个示例,可以在 The Shopify上找到网站或 GitHub 上,但我已经在Shopify论坛上也看到其他人使用它.
I cannot find a single example of {%-
in the Liquid documentation, either on the Shopify site, or on GitHub, but I've seen other people use it on the Shopify forums, too.
添加-
表示什么?
推荐答案
连字符是一个新的语法选项,您可以使用它来禁止出现在源代码中的空白行.您可以在此处了解更多信息: https://shopify.github.io/liquid/basics /whitespace/
The hyphens are a new syntax option that you can use to suppress blank lines that would otherwise show up in the source. You can learn more about this here: https://shopify.github.io/liquid/basics/whitespace/
这篇关于Shopify:为什么Liquid有时会使用{%-而不是{%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!