diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-05-01 18:40:34 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-05-01 21:44:15 +0200 |
commit | 690b0f8ff5795318dfa3834a5a75d6623e7d934a (patch) | |
tree | 1112306f4c6fecc0966d880dec702c3804633deb /tpl/partials | |
parent | e2b067f0504ba41ef45786e2f83d7002bd13a7eb (diff) | |
download | hugo-690b0f8ff5795318dfa3834a5a75d6623e7d934a.tar.gz hugo-690b0f8ff5795318dfa3834a5a75d6623e7d934a.zip |
tpl: Add docshelper for template funcs
And fix some other minor related issues.
Updates #3418
Diffstat (limited to 'tpl/partials')
-rw-r--r-- | tpl/partials/init.go | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tpl/partials/init.go b/tpl/partials/init.go index a9d1f82fe..4ee3faf19 100644 --- a/tpl/partials/init.go +++ b/tpl/partials/init.go @@ -24,20 +24,25 @@ func init() { f := func(d *deps.Deps) *internal.TemplateFuncsNamespace { ctx := New(d) - examples := [][2]string{ - {`{{ partial "header.html" . }}`, `<title>Hugo Rocks!</title>`}, - } - - return &internal.TemplateFuncsNamespace{ + ns := &internal.TemplateFuncsNamespace{ Name: name, Context: func() interface{} { return ctx }, - Aliases: map[string]interface{}{ - "partial": ctx.Include, - "partialCached": ctx.getCached, - }, - Examples: examples, } + ns.AddMethodMapping(ctx.Include, + []string{"partial"}, + [][2]string{ + {`{{ partial "header.html" . }}`, `<title>Hugo Rocks!</title>`}, + }, + ) + + ns.AddMethodMapping(ctx.getCached, + []string{"partialCached"}, + [][2]string{}, + ) + + return ns + } internal.AddTemplateFuncsNamespace(f) |