Skip to content

goforgery/mustache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mustache

Build Status

Mustache template renderer for Forgery2.

Install

go get github.com/goforgery/mustache

Use

By default template files are found in a folder named ./views in the directory where Forgery2 is started.

package main

import(
    "github.com/goforgery/forgery2"
    "github.com/goforgery/mustache"
)

func main() {
    app := f.CreateApp()
    app.Engine(".html", mustache.Create())
    app.Get("/", func(req *f.Request, res *f.Response, next func()) {
        res.Render("index.html", map[string]string{"title": "Mustache"})
    })
    app.Listen(3000)
}

The above code will look for the file ./views/index.html.

For performance the parsed Mustache template can be cached in memory by passing true as the first argument to Create().

app.Engine(".html", mustache.Create(true))

The cache can be cleaned by calling Clean() at any time.

mustache.Clean(true)

Test

go test

About

Mustache template renderer for Forgery2.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published