Let’s assume I have a file apple.html inside the partials folder as follows:
<h1>{{ .Site.Params.author.name }}</h1>
-
In the first scenario, I can use it in
index.htmlas{{ partial "apple" . }}and it works as expected. -
In the second scenario, I have a string array that I obtain from
paramsinconfig.tomland use it to create the name of partial. The line of interest in theconfig.tomlfile would be something like:
[params]
[params.temp]
fruits = ["apple"]
In the index.html I want to do something like
{{ range .Site.Params.temp.fruits }}
{{ $var := . }}
{{ partial $var <Context> }}
{{ end }}
What should I replace <Context> with so that everything works and I have to make no (or minimal) changes to the apple.html.
I tried by using {{ partial $var (dict "Mypage" $) }}. The following still didn’t work:
<h1>{{ .Mypage.Params.author.name }}</h1>