嵌套液体自定义标签块
Nested liquid custom tag blocks
如果外部标签包含多个同级 liquid 标签,我无法编译一些嵌套的 liquid 标签。这有效:
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
但这不是
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
我收到以下错误:
Liquid Exception: Liquid syntax error (line 1): 'container' tag was never closed in /.../_posts/blah.markdown/#excerpt
Liquid Exception: Liquid syntax error (line 1): 'container' tag was never closed in _includes/head.html, included in _layouts/default.html
注意到第一个错误中的 #excerpt
了吗?如果我在前面的内容中添加一个摘录。一切正常。我的 head.html include 是带有新 jekyll 站点的默认 include:
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
删除头部的 if 语句也会使错误消失。我完全不明白为什么有多个兄弟姐妹会导致这个错误。这是我的简化插件代码:
module Jekyll
class RenderContainer < Liquid::Block
def initialize(tag_name, contain, tokens)
super
end
def render(context)
"<div class=\"container\">#{super}</div>"
end
end
class RenderInner < Liquid::Block
def initialize(tag_name, contain, tokens)
super
end
def render(context)
"<div class=\"inner\">#{super}</div>"
end
end
end
Liquid::Template.register_tag('container', Jekyll::RenderContainer)
Liquid::Template.register_tag('inner', Jekyll::RenderInner)
我刚刚 运行 遇到了同样的问题,显然这是一个 known bug。我试过你的插件和你无法在上面工作的液体标签:
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
... 一旦我将推荐的修复程序(见下文)添加到我的 config.yml
,代码就可以正常工作了。
excerpt_separator: ""
注意,将此位添加到配置文件后,请务必重新启动 Jekyll 服务。
如果外部标签包含多个同级 liquid 标签,我无法编译一些嵌套的 liquid 标签。这有效:
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
但这不是
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
我收到以下错误:
Liquid Exception: Liquid syntax error (line 1): 'container' tag was never closed in /.../_posts/blah.markdown/#excerpt
Liquid Exception: Liquid syntax error (line 1): 'container' tag was never closed in _includes/head.html, included in _layouts/default.html
注意到第一个错误中的 #excerpt
了吗?如果我在前面的内容中添加一个摘录。一切正常。我的 head.html include 是带有新 jekyll 站点的默认 include:
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
删除头部的 if 语句也会使错误消失。我完全不明白为什么有多个兄弟姐妹会导致这个错误。这是我的简化插件代码:
module Jekyll
class RenderContainer < Liquid::Block
def initialize(tag_name, contain, tokens)
super
end
def render(context)
"<div class=\"container\">#{super}</div>"
end
end
class RenderInner < Liquid::Block
def initialize(tag_name, contain, tokens)
super
end
def render(context)
"<div class=\"inner\">#{super}</div>"
end
end
end
Liquid::Template.register_tag('container', Jekyll::RenderContainer)
Liquid::Template.register_tag('inner', Jekyll::RenderInner)
我刚刚 运行 遇到了同样的问题,显然这是一个 known bug。我试过你的插件和你无法在上面工作的液体标签:
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
... 一旦我将推荐的修复程序(见下文)添加到我的 config.yml
,代码就可以正常工作了。
excerpt_separator: ""
注意,将此位添加到配置文件后,请务必重新启动 Jekyll 服务。