https://github.com/kudohamu/bip
Wrapper of pongo2.TemplateSet for go-bindata
https://github.com/kudohamu/bip
go go-bindata golang pongo2
Last synced: 4 months ago
JSON representation
Wrapper of pongo2.TemplateSet for go-bindata
- Host: GitHub
- URL: https://github.com/kudohamu/bip
- Owner: kudohamu
- License: mit
- Created: 2017-07-01T10:39:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-01T10:52:47.000Z (almost 9 years ago)
- Last Synced: 2024-06-20T15:42:34.192Z (almost 2 years ago)
- Topics: go, go-bindata, golang, pongo2
- Language: Go
- Size: 2.93 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bip
Wrapper of `pongo2.TemplateSet` for `go-bindata`
[](https://godoc.org/github.com/kudohamu/bip)
[](https://opensource.org/licenses/MIT)
## Motivation
When use `go-bindata` and `pongo2` in combination, it is troublesome to build every time rewrite views (**even using Must**).
So `bip` behaves what read from files every executions when in development, and read from bindata when in production.
## Usage
```go
package main
import (
...
)
var tplSet *bip.TemplateSet
var indexTpl bip.Template
func init() {
tplSet = bip.NewSet(asset.Asset) // asset is a package generated from bindata.
indexTpl = bip.Must(tplSet.FromFile("index.html"))
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if err := indexTpl.ExecuteWriter(bip.Context{}, w); err != nil {
fmt.Fprintf(w, err.Error())
}
})
http.ListenAndServe(":8080", nil)
}
```
if you use as production binary, you need to add `bip` to build tag.
```shell
$ go build -tags="bip ...other tags"
```
## Caution
`bip` depends on **master** of `pongo2`. **DO NOT** use v3.