Unknwon/macaron — pull request #21 by mephux (2014-11-21 19:32:46+00:00)
Title: [POC] Add bindata support for static files and templates.

This is a POC and not well implemented but I wanted to start a discussion on adding this type of feature into core Macaron as an option for static/render middleware.

I have been using bindata (https://github.com/jteeuwen/go-bindata) to pack my templates and public dir so I can simple ship one binary without additional files.

# Usage:

I just jump into both public and templates and run `go-bindata -o ../data/public/public.go -pkg "public"` respectively. Then I import and add BinData: to each middleware. Pretty simple concept.

```go
m.Use(macaron.Static(
path.Join(setting.StaticRootPath, "public"),
macaron.StaticOptions{
SkipLogging: false,
BinData: public.BinData(),
},
))

m.Use(macaron.Renderer(macaron.RenderOptions{
Directory: path.Join(setting.StaticRootPath, "templates"),
Funcs: []template.FuncMap{base.TemplateFuncs},
IndentJSON: macaron.Env != macaron.PROD,
BinData: templates.BinData(),
}))
```

Anyway, just wanted to get a discussion on the concept and see if we could get something like this into core.