我正在编辑由Shopify Liquid中的另一个开发人员编写的标题标签,不幸的是,我对语法非常困惑。我正在尝试在其中一项编辑中进行红宝石样式插值。例如,
{% assign title_content = teacher.name %}
{% include "layout/page_title", title: title_content %}
在纯红宝石中,将是这样的
{% assign title_content = "the name of the teacher is #{teacher.name}" %}
这将给出输出“老师的名字是bla bla”。我想知道是否可以使用液体shopify做类似的事情。
您可以使用capture
标记来构建变量,如下所示:
{% capture title_content %}
the name of the teacher is {{ teacher.name }}
{% endcapture %}
或者,您应该能够append
在分配过程中使用过滤器:
{% assign title_content = "the name of the teacher is " | append: teacher.name %}
无论如何,Liquid应该是一种“安全”的模板语言。因此,它的表现力不如例如ERB,它允许您使用任意的Ruby代码。但是,这可确保普通用户可以输入和更新模板,而不会冒在服务器上执行任意代码的风险。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句