【发布时间】:2016-08-25 00:39:05
【问题描述】:
如果外部标签包含多个同级液体标签,我无法编译一些嵌套的液体标签。这有效:
{% 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 包含是默认包含一个新的 jekyll 站点:
<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)
【问题讨论】: