Embed Binary Data
Package bindata is a helper module that allows to use in-memory static and template files for Macaron Instances.

Installation

1
go get github.com/go-macaron/bindata
Copied!

Usage

Using go-bindata convert your template and public directories into individual packages.
Import the packages and use them like the example below.
1
import (
2
"path/to/bindata/public"
3
"path/to/bindata/templates"
4
"github.com/go-macaron/bindata"
5
)
6
7
m.Use(macaron.Static("public",
8
macaron.StaticOptions{
9
FileSystem: bindata.Static(bindata.Options{
10
Asset: public.Asset,
11
AssetDir: public.AssetDir,
12
AssetNames: public.AssetNames,
13
Prefix: "",
14
}),
15
},
16
))
17
18
m.Use(macaron.Renderer(macaron.RenderOptions{
19
TemplateFileSystem: bindata.Templates(bindata.Options{
20
Asset: templates.Asset,
21
AssetDir: templates.AssetDir,
22
AssetNames: templates.AssetNames,
23
Prefix: "",
24
}),
25
}))
Copied!
Last modified 2yr ago
Copy link