2016-04-29 81 views
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) 

回答

0

我只是碰到了同样的问题,显然,这是一个known bug。我想你的插件和液体标签,你不能得到上述工作:

{% container %} 
    {% inner %} 
    Stuff Goes in here 
    {% endinner %} 
    {% inner %} 
    Stuff Goes in here 
    {% endinner %} 
{% endcontainer %} 

...有一次我加了建议修订(见下文),以我的config.yml,代码的工作之后。

excerpt_separator: "" 

请注意,请确保在将此位添加到配置文件后重新启动Jekyll服务。

+1

不错!感谢您回答近乎一年的问题! – jhummel