4 ZH_Tpongo2
Lunny Xiao edited this page 3 years ago

Tpongo2 中间件是 pongo2.v3 模板引擎的 Tango 支持。

安装

go get gitea.com/tango/tpongo2

示例

package main

import (
    "gitea.com/lunny/tango"
    "gopkg.in/flosch/pongo2.v3"
    "gitea.com/tango/tpongo2"
)

type RenderAction struct {
    tpongo2.Renderer
}

func (a *RenderAction) Get() error {
    return a.RenderString("Hello {{ name }}!", pongo2.Context{
        "name": "tango",
    })
}

func main() {
    o := tango.Classic()
    o.Use(tpongo2.New())
    o.Get("/", new(RenderAction))
}