1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
# Ace Proxy
[](https://app.wercker.com/project/bykey/013ef8bb0794bdc457c3f3f766677bff)
[](http://godoc.org/github.com/yosssi/ace-proxy)
[](https://coveralls.io/r/yosssi/ace-proxy?branch=master)
## Overview
Ace Proxy is a proxy for the Ace template engine. This proxy caches the options for the Ace template engine so that you don't have to specify them every time calling the Ace APIs.
## Usage
```go
package main
import (
"net/http"
"github.com/yosssi/ace"
"github.com/yosssi/ace-proxy"
)
var p = proxy.New(&ace.Options{
BaseDir: "views",
DynamicReload: true,
})
func handler(w http.ResponseWriter, r *http.Request) {
tpl, err := p.Load("base", "", nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := tpl.Execute(w, map[string]string{"Msg": "Hello Ace"}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
```
|