完全解释这个问题有点复杂,所以我只是给出有问题的细节。我正在使用一大堆包含来根据前面定义的变量生成页面中的内容部分。一切正常,直到我试图在另一个内容部分中包含内容部分。在第一个内容部分中,我调用"选择器"包括根据"类型"决定使用哪些包括的内容。这似乎正确地看到了传入的变量的值。当"选择器"然后调用包含子内容类型的include,包括似乎接收外部内容的值。对我来说完全是无稽之谈!我错过了一些愚蠢的东西,还是这个错误?
"选择器":
resource!
{{ include.resource.type }}
{{ include.resource.title }}
{{ include.resource.term }}
{%- assign type = include.resource.type -%}
{%- if type == "document" %}{% include collection/type/document resource=include.resource -%}
{%- elsif type == "term" %}{% include collection/type/term resource=include.resource -%}
{%- elsif type == "youtube" %}{% include collection/type/youtube resource=include.resource -%}
{%- elsif type == "custom" %}{% include collection/type/custom resource=include.resource -%}
{%- else %}{% include error text="resource type not found" %}{% endif -%}
内部内容包括:
{%- assign resource = include.resource -%}
term:
{{ resource.type }}
{{ resource.title }}
{{ resource.term }}
{%- capture content -%}
{%- assign term = site.glossary | where: "name", resource.term | first -%}
{% unless term %}{% include error text="term not found" %}{% endunless %}
{{- term.content -}}
{%- endcapture -%}
{%- include collection/type/default title=resource.title content=content -%}
而不是预期的:
resource! term What is Git? gitterm: term What is Git? git
我明白了:
resource! term What is Git? gitterm: youtube Video!!!
下半部分是我对父母内容的期望......
可以找到相关的包含("选择器" =资源,内容类型包括=类型/术语)here。我可以找到我正在测试的页面和here(在CFRCR / _collection / intro_to_git.md的回购中的实时,来源)。