tl:dr : Can i compose a “hugo path” with strings passed as variables in the path ?
I have this :
(I fetch a specific data file going through my folder structure : Data → myPartial → en → mydata.yml)
index.html ↓
{{ partial "myPartial" (dict "ctx" . "data" (index .Site.Data.myPartial .Site.Language.Lang).mydata) }}
(then i access my data in a {{ with .data }} statement)
myPartial.html ↓
{{ with .data }}
<div>
<h3>{{ .title }}</h3>
<p>{{ .text }}</p>
</div>
{{ end }}
I would like to get this :
(I just indicate the file name in the key/value “data” → partial declaration gets dryer)
index.html ↓
{{ partial "myPartial" (dict "ctx" . "data" "mydata") }}
(then i access my data in a “recomposed hugo path”)
myPartial.html (PSEUDO code)↓
{{ with (index (printf site.Data.%s (hugorender "myPartial")) (printf .site.Language.Lang).%s (hugorender "data")) }}
<div>
<h3>{{ .title }}</h3>
<p>{{ .text }}</p>
</div>
{{ end }}
In essence “hugorender” would convert a string to an understandable “hugo command” at build time, i hope i’m clear.
What i’m asking is : is there an already possible way to do that (maybe with slice or delimit), or maybe i’ve overlooked something simple ?
Or is this idea in contradiction with how Hugo and Go fondamentaly works ?
Thanks for reading me !
PS : I know i can do {{ with (index .Site.Data.myPartial .Site.Language.Lang).mydata }} in myPartial but what if i have multiple myPartial calls and multiple data files as sources ? Hence my post