Jekyll 包含参数是否自动传递给子包含?
我一直在从事一个相当复杂的Jekyll项目,我很难理解继承如何处理包含的参数。结构是这样的: 我正在处理的文件:Jekyll 包含参数是否自动传递给子包含?,jekyll,liquid,Jekyll,Liquid,我一直在从事一个相当复杂的Jekyll项目,我很难理解继承如何处理包含的参数。结构是这样的: 我正在处理的文件: {%include test.html参数='foo'%} test.html: TEST{{include.param} {%include test2.html%} {%include test3.html param2='woo'%} test2.html: test2{{{include.param}} test3.html: test3{{include.param}{{i
{%include test.html参数='foo'%}
test.html:
TEST{{include.param}
{%include test2.html%}
{%include test3.html param2='woo'%}
test2.html:test2{{{include.param}}
test3.html:test3{{include.param}{{include.param2}}
输出为:测试foo测试2 foo测试3 woo
有时打印
{{include.param}
,有时不打印。为什么会这样?如果在模板中添加不带参数的include,它将继承其父级的所有参数
但是,如果将单个参数添加到子include,即使它与您尝试调用的参数不同,也会为后续子级重置include变量
在这种情况下,您仍然可以传递params,方法如下:
{%include test3.html param=include.param param2='woo'%}