gpt4 book ai didi

ruby - Dynamic 包含在 Jekyll 和 Liquid 中

转载 作者:数据小太阳 更新时间:2023-10-29 08:59:54 24 4
gpt4 key购买 nike

我正在构建我的第二个 Jekyll 站点,我正在尝试根据变量使页面布局引入不同的包含。

例如,在download.md中:

layout: page  
form: "free"
sidebar: "terms"

有了这个,站点将不再编译。它说

Liquid error (line 17): wrong number of arguments (4 for 3).

第 17 行是下面示例中的第一个 if 语句。

我应该如何设置这些包含?

<article class="s-article t-twocol__article">
<header class="s-article__header">
<h1 class="s-article__title">{{ page.title }}</h1>
<h4 class="s-article__lede">{{ page.lede }}</h4>
</header>
<div class="s-article__content">
{% if {{page.form}} == "full" %}
{% include c-form--full.html %}
{% endif %}
{% if {{page.form}} == "free" %}
{% include c-form--free.html %}
{% endif %}
{{ content }}
</div>
</article>

最佳答案

您没有看对地方。“第 17 行”是从一些流畅的解析角度来看的,与您的代码行编号无关。

真正的问题是您尝试在无效的 where 过滤器上使用 limit: nlimit: n(以及 offset: n)只能用于 for in 循环。

_layout/page.html - 第 47 行

{% assign cards = site.posts | where:"type","premium" limit:1 %}
{% for card in cards %}
..

必须改为:

{% assign cards = site.posts | where:"type","premium" %}
{% for card in cards limit:1 %}
..

并且您在 index.html 的第 21、25 和 43 行中又出现了三个,您可以在其中将 limit: nwhere 过滤到 for 循环。

关于ruby - Dynamic 包含在 Jekyll 和 Liquid 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38405227/

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