Build a single binary with templates

You can build a server into a single binary containing templates by using [go-bindata][https://github.com/go-bindata/go-bindata]'s AssetFile generated function.

  1. $ go get -u github.com/go-bindata/go-bindata/...
  2. $ go-bindata -fs -prefix "templates" ./templates/...
  3. $ go run .

Example Code:

  1. func main() {
  2. app := iris.New()
  3. tmpl := iris.HTML(AssetFile(), ".html")
  4. tmpl.Layout("layouts/layout.html")
  5. tmpl.AddFunc("greet", func(s string) string {
  6. return "Greetings " + s + "!"
  7. })
  8. app.RegisterView(tmpl)
  9. // [...]
  10. }

See complete examples at the _examples/view.