diff --git a/content/templates/functions.md b/content/templates/functions.md index d27e45035..88129aa1f 100644 --- a/content/templates/functions.md +++ b/content/templates/functions.md @@ -50,6 +50,29 @@ e.g. // Outputs Tags: tag1, tag2 and tag3 +### dict +Creates a dictionary (map[string, interface{}), expects parameters added in value:object fasion. +Invalid combinations like keys that are not strings or uneven number of parameters, will result in an exception thrown +Useful for passing maps to partials when adding to a template. + +e.g. Pass into "foo.html" a map with the keys "important, content" + + {{$important := .Site.Params.SomethingImportant }} + {{range .Site.Params.Bar}} + {{partial "foo" (dict "content" . "important" $important)}} + {{end}} + +"foo.html" + + Important {{.important}} + {{.content}} + + +or Create a map on the fly to pass into + + {{partial "foo" (dict "important" "Smiles" "content" "You should do more")}} + + ### echoParam Prints a parameter if it is set.