动态包括Jekyll with Liquid

时间:2016-07-15 21:24:07

标签: ruby dynamic include jekyll liquid

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

例如,在interface IEvent { type: string; [attachment: string]: any; } let myEvent: IEvent = { type: 'some-event-type' }; let eventType: string = myEvent["type"];

download.md

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

  

液体错误(第17行):参数数量错误(4为4)。

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

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

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

2 个答案:

答案 0 :(得分:2)

你不是在寻找合适的地方。 "第17行"从某些液体解析的角度来看,与您的代码行编号无关。

真正的问题是您尝试在无效的limit: n过滤器上使用wherelimit: 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 %}
    ..

在第21,25和43行的 index.html 中还有三次出现,您可以将limit: nwhere过滤器移至{{ 1}}循环。

答案 1 :(得分:0)

变化:

{% if {{page.form}} == "free" %}
{% if {{page.form}} == "full" %}

要:

{% if page.form == "free" %}
{% if page.form == "full" %}