renders is go template middleware for tango
Go to file
Lunny Xiao 0825a3f629
All checks were successful
checks / check and test (push) Successful in 32s
Use actions instead of drone
2023-04-20 15:41:17 +08:00
.gitea/workflows Use actions instead of drone 2023-04-20 15:41:17 +08:00
templates Added RenderBytes for Renderer and simplifed codes. 2015-05-10 23:18:37 +08:00
.gitignore fix test 2019-10-28 00:00:57 +08:00
funcs.go bug fixed for go-xorm/xorm#7 2016-04-09 22:33:48 +08:00
go.mod use go mod & add drone 2019-06-06 10:04:32 +08:00
go.sum update go.sum 2019-10-27 23:54:20 +08:00
LICENSE license 2015-04-28 15:48:51 +08:00
loader.go better error information when template is missing 2019-05-20 10:55:24 +08:00
options.go add http.FileSystem support and refactors 2017-03-29 17:17:53 +08:00
README.md Use actions instead of drone 2023-04-20 15:41:17 +08:00
renders_test.go fix test 2019-10-28 00:00:57 +08:00
renders.go migrate to gitea.com/lunny/tango 2019-03-26 15:56:05 +08:00

Renders

Middleware renders is a go template render middlewaer for Tango.

Version

v0.2.0510 Added RenderBytes for Renderer and simplifed codes.

Installation

go get gitea.com/tango/renders

Simple Example

type RenderAction struct {
    renders.Renderer
}

func (x *RenderAction) Get() {
    x.Render("test.html", renders.T{
        "test": "test",
    })
}

func main() {
    t := tango.Classic()
    t.Use(renders.New(renders.Options{
        Reload: true, // if reload when template is changed
        Directory: "./templates", // Directory to load templates
        Funcs: template.FuncMap{
            "test": func() string {
                    return "test"
            },
        },
        // Vars is a data map for global
        Vars: renders.T{
            "var": var,
        }
        Charset: "UTF-8", // Appends the given charset to the Content-Type header. Default is UTF-8
        // Allows changing of output to XHTML instead of HTML. Default is "text/html"
        HTMLContentType: "text/html",
        DelimsLeft:"{{",
        DelimsRight:"}}", // default Delims is {{}}, if it conflicts with your javascript template such as angluar, you can change it.
    }))
}

License

This project is under BSD License. See the LICENSE file for the full license text.