【问题标题】:Jekyll: Liquid filter "cgi_escape" returns error for some variablesJekyll:液体过滤器“cgi_escape”为某些变量返回错误
【发布时间】:2015-12-23 20:05:19
【问题描述】:

简短版本:您是否设法在{% include %}-ed 部分中使用了{{ page.title | cgi_escape }} 之类的东西?

详情如下:

我有一个像这样使用的部分:

{% include mainContainer.html %}

工作正常。然后,在那部分中,尝试显示一些液体变量:

{{ page.title }} 显示标题。

{{ page.content }} 显示内容。

{{ page.content | cgi_escape }} 显示内容,但已转义。

{{ page.title | cgi_escape }} 根本不起作用。产生以下错误:

Liquid Exception: undefined method `encoding' for nil:NilClass 

除了{{ page.content }} 之外,我收到任何{{ page }} 变量(类别、标题等)的错误,但在没有过滤器的情况下 都会正常显示。此外,{{ page.title | cgi_escape }} 在布局的...uhhh...'content' 部分也可以正常工作(我不知道该怎么称呼它——{{ content }} 部分)。我似乎只收到{% include %}的错误

【问题讨论】:

标签: jekyll shopify liquid


【解决方案1】:

没关系。构建失败是因为一些使用{% include mainContainer.html %} 的页面没有任何front matter,因此没有page.title(或其他)。显然,如果未设置变量,Liquid 愿意让{{ page.title }} 通过,但不会让{{ page.title | cgi_encode }}

【讨论】:

    猜你喜欢
    • 2014-03-15
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-04
    • 1970-01-01
    • 2020-05-15
    相关资源
    最近更新 更多