GitHub - anthonylehecka/intheHOAB: Hugo Version for the entire project
Lines in question from Layouts/Pages-Shared-Layouts/
Aside: All I was really trying to do was call a partial with a variable name but have given up on that for today, even with many sites saying it can be done.
Ok, let’s go to Plan B. No case statement in Hugo but {{ with }} was suggested.
Start with what works. A-OK, no problems
{{ partial “partial-Poet-Dante.html” . }}
Then go to the {{ with }} version, one for each of 24+ posts. Yes this is stupid, but if someone can show me a working {{ partial $usethispartial . }}, I’ll use it. Been through printf, Nils and nulls and partial is expecting a string etc. Keeps insisting it’s not a string.
Back to the problem code:
{{ $callthispartial := .Params.bodyContentPartial }}
{{ with (eq $callthispartial “partial-Poet-Dante.html”) }}
{{ partial “partial-Poet-Dante.html” . }}
{{ end }}
Gives me
render: failed to render pages: render of “page” failed: “C:\Hugo\Sites\InTheHeartOfAllBeings\layouts\Pages-Shared-Layouts\Post-Godly-Quality.html:57:11”: execute of template failed at <partial “partial-Poet-Dante.html” .>: error calling partial: “C:\Hugo\Sites\InTheHeartOfAllBeings\layouts\partials\partial-Poet-Dante.html:14:24”: execute of template failed at <.Params.Post_Sanskrit_Text>: can’t evaluate field Params in type bool
C:\Hugo\Sites\InTheHeartOfAllBeings\layouts\Pages-Shared-Layouts\Post-Godly-Quality.html:57:11:
The only difference is I am now calling the partial inside of the {{ with }}. The key message seems to be “can’t evaluate field Params in type bool”
Oddly enough, this works when {{ with }} is changed to if
{{ if eq $callthispartial “partial-Poet-Dante.html” }}
{{ partial “partial-Poet-Dante.html” . }}
{{ end }}
That works fine. It seems to be limited to the {{ with }} block.