-
Notifications
You must be signed in to change notification settings - Fork 22
/
gonja.go
34 lines (28 loc) · 914 Bytes
/
gonja.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
30
31
32
33
34
package gonja
import (
"github.com/noirbizarre/gonja/config"
"github.com/noirbizarre/gonja/exec"
"github.com/noirbizarre/gonja/loaders"
)
var (
// DefaultLoader is being used by the DefaultSet.
DefaultLoader = loaders.MustNewFileSystemLoader("")
// DefaultEnv is an environment created for quick/standalone template rendering.
DefaultEnv = NewEnvironment(config.DefaultConfig, DefaultLoader)
// Methods on the default set
FromString = DefaultEnv.FromString
FromBytes = DefaultEnv.FromBytes
FromFile = DefaultEnv.FromFile
FromCache = DefaultEnv.FromCache
// Globals for the default set
Globals = DefaultEnv.Globals
)
// Must panics, if a Template couldn't successfully parsed. This is how you
// would use it:
// var baseTemplate = gonja.Must(gonja.FromFile("templates/base.html"))
func Must(tpl *exec.Template, err error) *exec.Template {
if err != nil {
panic(err)
}
return tpl
}