Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jekyll 与杰基尔';s液体语法,I';I’我想在循环中使用include,但它会出错_Jekyll_Liquid - Fatal编程技术网

Jekyll 与杰基尔';s液体语法,I';I’我想在循环中使用include,但它会出错

Jekyll 与杰基尔';s液体语法,I';I’我想在循环中使用include,但它会出错,jekyll,liquid,Jekyll,Liquid,以下代码错误表示“include标记的语法无效。文件包含无效字符或序列:photo-container.html category='korean'image='custom/gallery/korean/1.jpg'有效语法:{%include File.ext param='value'param2='value'%}” 我想知道这是否可能,如果可能,如何实现。在jekyll Includes中,可以将参数作为字符串或变量传递,如{%include p.html param1=“my str

以下代码错误表示“include标记的语法无效。文件包含无效字符或序列:photo-container.html category='korean'image='custom/gallery/korean/1.jpg'有效语法:{%include File.ext param='value'param2='value'%}”


我想知道这是否可能,如果可能,如何实现。

在jekyll Includes中,可以将参数作为字符串或变量传递,如
{%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 %}
{% 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 %}