blob: 54c2ba94cf418e8ac4749fc2c523e06536bb0eaa (
plain)
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
|
package main
import (
"io"
"io/ioutil"
"os"
"strings"
)
// Reads all .txt files in the current folder
// and encodes them as strings literals in textfiles.go
func main() {
fs, _ := ioutil.ReadDir("templates/")
out, _ := os.Create("templates.go")
out.Write([]byte("package main \n\nconst (\n"))
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".tmpl") {
out.Write([]byte(strings.TrimSuffix(f.Name(), ".tmpl") + " = `"))
f, _ := os.Open("templates/" + f.Name())
io.Copy(out, f)
out.Write([]byte("`\n"))
}
}
out.Write([]byte(")\n"))
out.Write([]byte("func getTemplate() string {\n"))
out.Write([]byte(`return "{{define \"block_facebook.tmpl\"}}" + block_facebook + "{{end}}{{define \"cache_static.tmpl\"}}" + cache_static + "{{end}} {{define \"pagespeed.tmpl\"}}" + pagespeed + "{{end}} {{define \"robots.tmpl\"}}" + robots + "{{end}} {{define \"ssl.tmpl\"}}" + ssl + "{{end}}" + server`))
out.Write([]byte("\n\n}\n"))
out.Write([]byte("func isGenerated() bool { return true }\n"))
}
|