【发布时间】:2017-02-24 16:15:54
【问题描述】:
我不熟悉使用 Hugo 和 Go 模板。如何使用 Hugo 从基本文件中定义的部分文件中访问变量?
例如:我有一个index.html 文件,其中包含读取存储在数据目录中events.json 文件中的数据并将其存储在变量中的代码。如何从另一个文件访问该变量?
index.html
{{ $events := .Site.Data.events }}
{{ partial "people" . }}
people.html
// access the events variable from the index.html
{{ $events }}
我真的希望这是有道理的。如果需要,我可以尝试澄清更多。
【问题讨论】:
标签: global-variables template-engine partials go-templates hugo