func populateTemplatesMap(tSet *pongo2.TemplateSet, tMap map[string]*pongo2.Template) error { templates := []string{ "index.html", "paste.html", "404.html", "401.html", "oops.html", "display/audio.html", "display/image.html", "display/video.html", "display/pdf.html", "display/bin.html", "display/file.html", } for _, tName := range templates { tpl, err := tSet.FromFile(tName) if err != nil { return err } tMap[tName] = tpl } return nil }
package pobin_test import ( "github.com/flosch/pongo2" . "github.com/sharpner/pobin" "github.com/sharpner/pobin/assets" "github.com/sharpner/pobin/fallback" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Test the loader", func() { Context("No Fallback loading works", func() { var ( loader pongo2.TemplateLoader templateSet *pongo2.TemplateSet ) BeforeEach(func() { loader = NewMemoryTemplateLoader(assets_test.Asset) templateSet = pongo2.NewSet("testing", loader) }) It("should be validly parsed", func() { loginTemplate, err := templateSet.FromFile("templates/sites/index.tpl") Expect(err).ToNot(HaveOccurred()) out, err := loginTemplate.Execute(pongo2.Context{ "action": "/login", })