tplimpl: Add built-in print funcs to FuncMap
authorCameron Moore <moorereason@gmail.com>
Tue, 7 Mar 2017 20:11:03 +0000 (14:11 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 8 Mar 2017 23:21:55 +0000 (00:21 +0100)
Add print, printf, and println to the Hugo FuncMap so that they are
accessible to the apply template func.

Updates #3139

tpl/tplimpl/template_funcs.go
tpl/tplimpl/template_funcs_test.go

index d4eec5b2f4471ebd76777c91d83f3ac997817d3f..05382825bd2a22c5158844805ab0266d422955d1 100644 (file)
@@ -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,
index 942e4e4094d773eb85bc3c9191f86ef69441c4d0..491eac56ca0086e6ff9337772bccd50bf011b5da 100644 (file)
@@ -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