2016-10-29 16 views
1

下面的代碼錯誤說「包含標記的語法無效。文件包含無效字符或序列:photo-container.html category ='korean '形象=' 定製/畫廊/韓國/ 1.JPG」有效的語法:{%包括file.ext PARAM = '值' 參數2 = '值' %}」使用Jekyll的Liquid語法,我想使用包含在一個循環中,但它錯誤

 {% for i in (1..1) %} 
     {% include photo-container.html category='korean' image='custom/gallery/korean/{{i}}.jpg' %} 
     {% endfor %} 

我不知道這是可能的,並如果是,如何。

回答

1

在jekyll夾雜物中,您可以將參數作爲字符串或變量傳遞,如{% include p.html param1="my string" param2=myVar %}。但是一個字符串中的變量不會被處理。

解決方案是連接您的字符串並將其分配給一個變量。

{% capture myVar %}My string text {{ anyVar }} text end{% end capture %} 
or 
{% assign myVar="My string text" | append: anyVar | append: "text end" %} 
{% include page.html param1=myVar %} 
相關問題