Pongo2模板引擎

    示例

    1. import (
    2. "github.com/lunny/tango"
    3. "gopkg.in/flosch/pongo2.v3"
    4. "github.com/tango-contrib/tpongo2"
    5. )
    6. tpango2.Renderer
    7. func (a *RenderAction) Get() error {
    8. return a.RenderString("Hello {{ name }}!", pongo2.Context{
    9. "name": "tango",
    10. })
    11. }
    12. //模板有改动自动重载
    13. var options = struct {
    14. Suffix string
    15. }{
    16. Reload: true,
    17. TemplatesDir: "./templates",
    18. Suffix:".html",
    19. }
    20. func main() {
    21. o := tango.Classic()
    22. o.Use(tpango2.New(options))//加入自动重载
    23. }