如果外部标签包含多个兄弟液体标签,我在编译嵌套液体标签时遇到问题。这有效:
{% 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网站:
<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)
答案 0 :(得分:0)
我刚遇到同样的问题,显然这是一个known bug。我尝试了你的插件和液体标签,你无法在上面工作:
{% container %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% inner %}
Stuff Goes in here
{% endinner %}
{% endcontainer %}
...一旦我将推荐的修复程序(见下文)添加到我的config.yml
,代码就会在此之后运行。
excerpt_separator: ""
注意,确保在将此位添加到配置文件后重新启动Jekyll服务。