aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/internal
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-01-07 10:23:24 +0100
committerBjørn Erik Pedersen <[email protected]>2020-01-07 13:18:19 +0100
commit1cf235412f98b42aefe368e99a0e9e95bae6eef7 (patch)
tree0a73bcff5a768153e3ef36ff2f563a3e3418c255 /tpl/internal
parentdf6e9efd8f345707932231ea23dc8713afb5b026 (diff)
downloadhugo-1cf235412f98b42aefe368e99a0e9e95bae6eef7.tar.gz
hugo-1cf235412f98b42aefe368e99a0e9e95bae6eef7.zip
tpl: Put Go's internal template funcs in Hugo's map
``` name old time/op new time/op delta SiteNew/Many_HTML_templates-16 43.4ms ± 0% 42.7ms ± 0% -1.71% (p=0.016 n=4+5) name old alloc/op new alloc/op delta SiteNew/Many_HTML_templates-16 17.5MB ± 0% 17.5MB ± 0% ~ (p=0.690 n=5+5) name old allocs/op new allocs/op delta SiteNew/Many_HTML_templates-16 247k ± 0% 247k ± 0% ~ (p=0.310 n=5+5) ``` Fixes #6717
Diffstat (limited to 'tpl/internal')
-rw-r--r--tpl/internal/go_templates/htmltemplate/hugo_template.go3
-rw-r--r--tpl/internal/go_templates/texttemplate/hugo_template.go3
2 files changed, 6 insertions, 0 deletions
diff --git a/tpl/internal/go_templates/htmltemplate/hugo_template.go b/tpl/internal/go_templates/htmltemplate/hugo_template.go
index 117d85e49..eba54fbbf 100644
--- a/tpl/internal/go_templates/htmltemplate/hugo_template.go
+++ b/tpl/internal/go_templates/htmltemplate/hugo_template.go
@@ -24,6 +24,9 @@ package is auto generated.
*/
+// Export it so we can populate Hugo's func map with it, which makes it faster.
+var GoFuncs = funcMap
+
// Prepare returns a template ready for execution.
func (t *Template) Prepare() (*template.Template, error) {
if err := t.escape(); err != nil {
diff --git a/tpl/internal/go_templates/texttemplate/hugo_template.go b/tpl/internal/go_templates/texttemplate/hugo_template.go
index d881064e5..37fa969da 100644
--- a/tpl/internal/go_templates/texttemplate/hugo_template.go
+++ b/tpl/internal/go_templates/texttemplate/hugo_template.go
@@ -29,6 +29,9 @@ package is auto generated.
*/
+// Export it so we can populate Hugo's func map with it, which makes it faster.
+var GoFuncs = builtinFuncs
+
// Preparer prepares the template before execution.
type Preparer interface {
Prepare() (*Template, error)