2
如果外層標籤包含多個兄弟液體標籤,我無法獲得一些嵌套液體標籤進行編譯。這工作:嵌套液體定製標籤塊
{% 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包括是默認的一個新的哲基爾網站:
<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)
不錯!感謝您回答近乎一年的問題! – jhummel