parent
54e02903e4
commit
34ff32586a
@ -0,0 +1,9 @@
|
||||
// +build !vfs
|
||||
//go:generate go run assets_generate.go
|
||||
|
||||
package main
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Assets contains project assets.
|
||||
var Assets http.FileSystem = http.Dir("res")
|
@ -0,0 +1,23 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/shurcooL/vfsgen"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var fs http.FileSystem = http.Dir("res")
|
||||
|
||||
err := vfsgen.Generate(fs, vfsgen.Options{
|
||||
PackageName: "main",
|
||||
BuildTags: "vfs",
|
||||
VariableName: "Assets",
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// +build !bindata
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func init() {
|
||||
fs := http.FileServer(http.Dir(templateDir))
|
||||
http.Handle("/res/", http.StripPrefix("/res/", fs))
|
||||
}
|
||||
|
||||
func executeTemplate(wr io.Writer, name string, data interface{}) {
|
||||
path := filepath.Join(templateDir, name+".html")
|
||||
body, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
template.Must(template.New("t").Delims("[[", "]]").Parse(string(body))).Execute(wr, data)
|
||||
}
|
Loading…
Reference in new issue