if no loader present provide default
This commit is contained in:
parent
1977a5f4ff
commit
05e3020554
@ -12,13 +12,12 @@ import (
|
||||
var Suffix = ".html.twig"
|
||||
|
||||
type Pongo struct {
|
||||
set *pongo2.TemplateSet
|
||||
basedir string
|
||||
set *pongo2.TemplateSet
|
||||
}
|
||||
|
||||
func (p *Pongo) Instance(name string, data interface{}) render.Render {
|
||||
r := new(PongoRenderer)
|
||||
tpl, e := p.set.FromCache(fmt.Sprintf("%s%s%s", p.basedir, name, Suffix))
|
||||
tpl, e := p.set.FromCache(fmt.Sprintf("%s%s", name, Suffix))
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
@ -53,9 +52,10 @@ func New(basedir string, debug bool, loaders ...pongo2.TemplateLoader) *Pongo {
|
||||
if !strings.HasSuffix(basedir, "/") {
|
||||
basedir = basedir + "/"
|
||||
}
|
||||
p.basedir = basedir
|
||||
if len(loaders) > 0 {
|
||||
p.set.AddLoader(loaders...)
|
||||
} else {
|
||||
p.set.AddLoader(pongo2.MustNewLocalFileSystemLoader(basedir))
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user