I’ve solved my problem a different way, so this is not blocking my work. However, it has caused me several hours of pain today, so wondering if anyone can shed some light on this.
Now let’s say the resultant $x provides the following text:
$s.somekey
In the context of code such as the following:
{{- range $fname, $s := index .Site.Data.hosts -}}
{{- if eq $fname ($company) -}}
{{ $s.somekey }}
{{end}}
{{end}}
The problem is, that even though the command to retrieve the data "$s.somekey " renders as text, it simply prints the command rather than obtains the data.
I.e. you will get in the html:
$s.somekey
Rather than:
"This is the data that was retrieved".
I am interested if anyone can shed some context on why this is?
I am trying to access items in the data file within the range command. My code above was overly simplified, but lets give a more real example of one variation of code I tried
{{- range $fname, $s := index .Site.Data.hosts -}}
{{- if eq $fname ($companyid1) -}}
{{ (printf "$s.%sopinionsummary" ($.Params.typeid)) }}
{{end}}
{{end}}
For example, all that does is print:
$s.typeopinionsummary
Whereas the following code (when I add it manually), prints the data:
{{- range $fname, $s := index .Site.Data.hosts -}}
{{- if eq $fname ($companyid1) -}}
{{ $s.typeopinionsummary }}
{{end}}
{{end}}