【问题标题】:Failing in liquid include if parameter not set如果未设置参数,则在液体中失败
【发布时间】:2020-05-07 19:28:15
【问题描述】:

假设我有一个 include sn-p foo.html 像这样:

<a href="table/{{include.file}}.html">
    <img src="{{include.file}}.svg" alt="{{ include.alt | default: 'Figure' }}">
</a>

这应该被称为:

{% include foo.html file="blah" %}

如果缺少file="blah" 部分(没有有用的默认值),我想通过诊断使液体运行失败。

【问题讨论】:

    标签: liquid


    【解决方案1】:

    你可以试试这个代码:

     {% include 'foo.html', file:'blah' %}
    

    【讨论】:

      猜你喜欢
      • 2010-09-18
      • 1970-01-01
      • 2023-03-05
      • 2014-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2014-06-09
      相关资源
      最近更新 更多