From 05e3020554992cb75a53393b93461b8edfb39603 Mon Sep 17 00:00:00 2001 From: Darko Luketic <2694548+dalu@users.noreply.github.com> Date: Thu, 19 Mar 2020 21:56:28 +0100 Subject: [PATCH] if no loader present provide default --- render.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/render.go b/render.go index ebd9595..9788772 100644 --- a/render.go +++ b/render.go @@ -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 }