https://github.com/lestrrat-go/tmplbox
Yet Another (text|html)/template wrapper
https://github.com/lestrrat-go/tmplbox
Last synced: 4 months ago
JSON representation
Yet Another (text|html)/template wrapper
- Host: GitHub
- URL: https://github.com/lestrrat-go/tmplbox
- Owner: lestrrat-go
- License: mit
- Created: 2016-09-09T02:05:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T21:03:13.000Z (over 7 years ago)
- Last Synced: 2025-01-09T03:41:42.392Z (6 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tmplbox
Yet Another (text|html)/template wrapper
[](https://travis-ci.org/lestrrat-go/tmplbox)
[](https://godoc.org/github.com/lestrrat-go/tmplbox)
# SYNOPSIS
```html
{{ define "root" }}
{{ block "content" }}{{ end }}
{{ end }}
``````html
{{ define "content" }}Hello, World!{{ end }}
``````go
// assuming you're using go-bindata's Asset function to
// retrieve template sources here.
var box := tmplbox.New(tmplbox.AssetSourceFunc(Asset))func indexHandler(w http.ResponseWriter, r *http.Response) {
// Assuming you have a dependency between index.html and
// base.html (see above), GetOrCompose will automatically
// compile and merge all of the specified templates.
t, _ := box.GetOrCompose("index.html", "base.html")// Will output
//
//
//
// Hello, World!
//
//
t.ExecuteTemplate(w, "root", nil)
}
```# FEATURES
* Plays well with go-bindata
* Easy to setup template dependency to emulate "extends", without another big library