-
Notifications
You must be signed in to change notification settings - Fork 0
/
pimp.go
29 lines (24 loc) · 879 Bytes
/
pimp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package pimp
import (
"io"
ttemplate "text/template"
"github.com/aymericbeaumet/pimp/pkg/funcs"
"github.com/aymericbeaumet/pimp/pkg/script"
"github.com/aymericbeaumet/pimp/pkg/template"
)
// ExecuteScript executes a PimpScript and writes the output to the given
// writer. Any error from a template function immediately aborts and is
// returned.
func ExecuteScript(w io.Writer, text string) error {
return script.Execute(w, text, "{{", "}}", FuncMap())
}
// RenderTemplate renders the template and writes the output to the given
// writer.
func RenderTemplate(w io.Writer, text string) error {
return template.Render(w, text, "{{", "}}", FuncMap())
}
// FuncMap returns a newly allocated funcmap containing all the pimp template
// functions. This can be used with the standard Go module `text/template`.
func FuncMap() ttemplate.FuncMap {
return funcs.FuncMap()
}