func (self *PongoTemplate) Render(output io.Writer, payload map[string]interface{}) error { if self.template != nil { return self.template.ExecuteWriter(pongo2.Context(payload), output) } else { return fmt.Errorf("Cannot execute nil template") } }
func executeTemplate(template string, vars PlanVars) (string, error) { tmpl, err := pongo2.FromString(template) if err != nil { return "", err } return tmpl.Execute(pongo2.Context(vars)) }
func BenchmarkDebugWrapper(b *testing.B) { r := renderDebug.Instance("index.tpl", pongo2.Context{"data": "test data"}).(Pongo) for n := 0; n < b.N; n++ { ctx := pongo2.Context(r.Data.(pongo2.Context)) err := r.Template.ExecuteWriterUnbuffered(ctx, ioutil.Discard) if err != nil { b.Fatal(err) } } }
func pongo2() gin.HandlerFunc { return func(c *gin.Context) { c.Next() tmpl, context, err := getContext(c) if err == nil { c.HTML(http.StatusOK, tmpl+conf.TMPL_SUFFIX, p.Context(context)) } else { log.DebugPrint("Render Error: %v", err) } } }
func (p Pongo) Render(w http.ResponseWriter) error { ctx := pongo2.Context(p.Data.(pongo2.Context)) w.Header().Set("Content-Type", "text/html; charset=utf-8") return p.Template.ExecuteWriter(ctx, w) }
// Execute - Executes template with context. func (t *pongoTemplate) Execute(ctx Context, w io.Writer) (err error) { err = t.Template.ExecuteWriter(pongo2.Context(ctx), w) return }
func (node *mapNodeTemplate) Execute(ctx Context) (interface{}, error) { res, err := node.template.Execute(pongo2.Context(ctx)) return res, err }
func (p Pongo2) Render(w http.ResponseWriter) error { p.writeContentType(w, htmlContentType) c := pongo2.Context(p.Data.(Context)) return p.Template.ExecuteWriter(c, w) }