【问题标题】:Jekyll - Liquid Exception: Unknown operator forloopJekyll - 液体异常:循环的未知运算符
【发布时间】:2013-07-16 16:14:41
【问题描述】:

我已经更新了 jekyll,现在出现这个错误:

Liquid Exception: Unknown operator forloop in collection.html

这是有问题的代码:

{% for tag in site.content_data.tags %}{{ tag }}{% if not forloop.last %}, {% endif %}{% endfor %}

我该如何解决这个错误?

【问题讨论】:

    标签: for-loop jekyll liquid


    【解决方案1】:

    我怀疑您的 {% if not forloop.last %} 不是有效语法,因为我在 operators section 中没有看到它。

    你试过{% if forloop.last == false %}吗?

    【讨论】:

    • 面临完全相同的问题。错误的原因是您可以检查变量是否像 {% if variable %} 那样传递到渲染中。也许应该改变这种行为以获得更好的平等性。
    【解决方案2】:

    不与曾易相矛盾,但您也可以使用以下方法解决此问题:

    {% unless forloop.last %}something{% endunless %} 
    

    【讨论】:

      猜你喜欢
      • 2012-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 2020-08-22
      相关资源
      最近更新 更多