-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.go
45 lines (36 loc) · 756 Bytes
/
js.go
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
package txttmpl
import (
"bytes"
"text/template"
"github.com/devlights/gomy/output"
)
// Js -- text/template の テンプレート仕様 における js のサンプルです.
//
// # REFERENCES
// - https://pkg.go.dev/text/template@latest
func Js() error {
var (
tmpls = []string{
`{{ printf "%s:%s" . (js .) }}`,
}
)
for _, t := range tmpls {
var (
tmpl *template.Template
buf bytes.Buffer
err error
)
output.Stdoutl("[template]", t)
tmpl, err = template.New("Js").Parse(t)
if err != nil {
return err
}
err = tmpl.Execute(&buf, struct{ Hello, World string }{"><://=&", "world"})
if err != nil {
return err
}
output.Stdoutf("[tmpl]", "%q\n", buf.String())
output.StdoutHr()
}
return nil
}