2016-04-29 80 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