gpt4 book ai didi

ruby - 'for' 标签从未关闭/如果 elsif else 在液体逻辑中包含页面?

转载 作者:太空宇宙 更新时间:2023-11-03 16:12:39 25 4
gpt4 key购买 nike

我的 Jekyll 版本是 3.8.6。

如果我有太多 elseif,我会得到一个 for 逻辑错误,其中没有写入 for 循环。如果我删除一个 elseif,它会起作用。

这不起作用:

{% if page.jsontype == "page" %}
{% include pageJSONLD.html %}
{% elsif page.jsontype == "collection" %}
{% include collectionJSONLD.html %}
{% elsif page.jsontype == "post" %}
{% include postJSONLD.html %}
{% elsif page.jsontype == "about" %}
{% include aboutJSONLD.html %}
{% elsif page.jsontype == "lawyer" %}
{% include lawyerJSONLD.html %}
{% elsif page.jsontype == "contact" %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endif %}

这行得通!

{% if page.jsontype == "page" %}
{% include pageJSONLD.html %}
{% elsif page.jsontype == "post" %}
{% include postJSONLD.html %}
{% elsif page.jsontype == "about" %}
{% include aboutJSONLD.html %}
{% elsif page.jsontype == "lawyer" %}
{% include lawyerJSONLD.html %}
{% elsif page.jsontype == "contact" %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endif %}

我得到的附加 elsif 的错误是

Jekyll Feed: Generating feed for posts Liquid Exception: Liquid syntax error (/home/xxxxx/repositories/legal/_includes/_head.html line 100): 'for' tag was never closed included in /_layouts/default.html Error: Liquid syntax error (/home/xxxx/repositories/legal/_includes/_head.html line 100): 'for' tag was never closed included Error: Run jekyll build --trace for more information.

第 100 行是 {% elsif page.jsontype == "lawyer"%}

编辑 1:

我在使用 case/when 时遇到了同样的错误

{% case page.jsontype %}
{% when 'page' %}
{% include pageJSONLD.html %}
{% when 'collection' %}
{% include collectionJSONLD.html %}
{% when 'post' %}
{% include postJSONLD.html %}
{% when 'about' %}
{% include aboutJSONLD.html %}
{% when 'lawyer' %}
{% include lawyerJSONLD.html %}
{% when 'contact' %}
{% include contactJSONLD.html %}
{% else %}
{% include homeJSONLD.html %}
{% endcase %}

它仍然显示指向头文件末尾的相同错误。

最佳答案

在我对 Jekyll 3.8.5 和 Jekyll 4.0.0 的测试中,这两种情况都非常有效,没有错误,没有限制:

如果/否则:

{% if page.jsontype == "page" %}
{% include 1.html %}
{% elsif page.jsontype == "collection" %}
{% include 2.html %}
{% elsif page.jsontype == "post" %}
{% include 3.html %}
{% elsif page.jsontype == "about" %}
{% include 4.html %}
{% elsif page.jsontype == "lawyer" %}
{% include 5.html %}
{% elsif page.jsontype == "contact" %}
{% include 6.html %}
{% else %}
{% include 7.html %}
{% endif %}

案例/时间:

{% case page.jsontype %}
{% when 'page' %}
{% include 1.html %}
{% when 'collection' %}
{% include 2.html %}
{% when 'post' %}
{% include 3.html %}
{% when 'about' %}
{% include 4.html %}
{% when 'lawyer' %}
{% include 5.html %}
{% when 'contact' %}
{% include 6.html %}
{% else %}
{% include 7.html %}
{% endcase %}

任何丢失的 {% endfor %},也在包含文件中,显示相同的错误消息但正确的行:

Liquid Exception: Liquid syntax error (C:/Users/User/Desktop/ruby_projects/jekyll_test/testpage/_includes/3.html line 9): 'for' tag was never closed included in /_layouts/default.html jekyll 3.8.6 | Error: Liquid syntax error (C:/Users/User/Desktop/ruby_projects/jekyll_test/testpage/_includes/3.html line 9): 'for' tag was never closed included

我最后的想法之一是您添加和删除了一个特定的页面,例如collectionJSONLD.html 每次测试时(正如您确认的那样)。由于您尚未发布项目的完整代码,因此必须有一个特定的东西我们看不到。尽管如此,很高兴看到您解决了它!这是一个艰难的过程:)

关于ruby - 'for' 标签从未关闭/如果 elsif else 在液体逻辑中包含页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57878564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com