Closed yacoob closed 9 years ago
I understand what you are asking to do. Not sure what the best solution is for it today. Would need to think about a good solution.
Any update on this?
Is it possible for to declare a map as a variable and pass that?
Ran into this issue today as well - wasn't sure if my understanding of Go template was bad, or if there's no good way. I would have spent less time getting stuck if documentation mentioned that there's no good way. I was trying to migrate a Jekyll theme, and Jekyll has a way to pass multiple parameters to its "includes" call.
It seems the best solution so far has been the .Scratch feature that @bep recently added.
@spf13 wow, thank you for a quick reply! @bep that's great!
For everyone else, here's the relevant pull request: https://github.com/spf13/hugo/pull/746
Hopefully the documentation page reflects the change soon: http://gohugo.io/extras/scratch
I don't think we'll gonna provide anything "smarter" than Scratch
anything soon, unless provided by the Go templates -- so close this. Hate open issues :-)
Oh, and until 0.13 gets out in the open -- the latest docs can be read nicely at https://github.com/spf13/hugo/blob/master/docs/content/extras/scratch.md
0.15 introduces a map that can be used for this https://github.com/spf13/hugo/pull/1463
See dict
function http://gohugo.io/templates/functions/#dict
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I'd like to know whether there's any best practice about passing extra arguments to a partial template. Let's assume I have a partial template like this:
I'd like to be able to use a single template to produce a button with
glyphicon-chevron-right
andglyphicon-chevron-left
. However, as far as I can tell:.
anddirection
key);{{ template "foo" bar }}
call;.
.Any other way to get this functionality? Currently I'm simply defining two separate templates, but that's clumsy.