hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 45b9d7223a8098f3c19871ec695c79384bc40871
parent a2a8a651f72f1ebd38a72eaf3fd4d83e4a73559f
Author: Cameron Moore <moorereason@gmail.com>
Date:   Tue,  7 Mar 2017 14:11:03 -0600

tplimpl: Add built-in print funcs to FuncMap

Add print, printf, and println to the Hugo FuncMap so that they are
accessible to the apply template func.

Updates #3139

Diffstat:
Mtpl/tplimpl/template_funcs.go | 3+++
Mtpl/tplimpl/template_funcs_test.go | 6++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tpl/tplimpl/template_funcs.go b/tpl/tplimpl/template_funcs.go
@@ -2152,6 +2152,9 @@ func (t *templateFuncster) initFuncMap() {
 		"partialCached": t.partialCached,
 		"plainify":      plainify,
 		"pluralize":     pluralize,
+		"print":         fmt.Sprint,
+		"printf":        fmt.Sprintf,
+		"println":       fmt.Sprintln,
 		"querify":       querify,
 		"readDir":       t.readDirFromWorkingDir,
 		"readFile":      t.readFileFromWorkingDir,
diff --git a/tpl/tplimpl/template_funcs_test.go b/tpl/tplimpl/template_funcs_test.go
@@ -148,6 +148,9 @@ md5: {{ md5 "Hello world, gophers!" }}
 mod: {{mod 15 3}}
 modBool: {{modBool 15 3}}
 mul: {{mul 2 3}}
+print: {{ print "works!" }}
+printf: {{ printf "%s!" "works" }}
+println: {{ println "works!" -}}
 plainify: {{ plainify  "Hello <strong>world</strong>, gophers!" }}
 pluralize: {{ "cat" | pluralize }}
 querify 1: {{ (querify "foo" 1 "bar" 2 "baz" "with spaces" "qux" "this&that=those") | safeHTML }}
@@ -221,6 +224,9 @@ md5: b3029f756f98f79e7f1b7f1d1f0dd53b
 mod: 0
 modBool: true
 mul: 6
+print: works!
+printf: works!
+println: works!
 plainify: Hello world, gophers!
 pluralize: cats
 querify 1: bar=2&baz=with+spaces&foo=1&qux=this%26that%3Dthose