Reputation: 2809
Say I have {{ partial "li.html" $test $root.Data.Term }}
.
With this I can can access the first parameter, or $test
, by simply refering to .
within the li.html
template, but how do I access the second or additional parameter ($root.Data.Term
) from within the same template?
Upvotes: 16
Views: 4470
Reputation: 481
I would suggest using the hugo dict function. It allows you to use key/value pairs to pass information. The documentation states that for your use case.
{{ partial "yourPartial" (dict "test" "yourTestData" "term" "yourTerm") }}
You can then access the values by just using {{ .test }} and {{ .term }}.
Alternatively you can use the scratch function, which is a more "global" approach.
Upvotes: 20