Skip to content

Commit e597857

Browse files
committed
Update main.go
1 parent 4a10e29 commit e597857

File tree

1 file changed

+36
-48
lines changed

1 file changed

+36
-48
lines changed

main.go

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// 🚀 Fiber is an Express inspired web framework written in Go with 💖
2-
// 📌 API Documentation: https://fiber.wiki
3-
// 📝 Github Repository: https://github.com/gofiber/fiber
4-
51
package template
62

73
import (
@@ -15,69 +11,61 @@ import (
1511
)
1612

1713
// Amber https://github.com/eknkc/amber
18-
func Amber() func(raw string, bind interface{}) (out string, err error) {
19-
return func(raw string, bind interface{}) (out string, err error) {
20-
var buf bytes.Buffer
21-
var tmpl *template.Template
14+
func Amber(raw string, binding interface{}) (out string, err error) {
15+
var buf bytes.Buffer
16+
var tmpl *template.Template
2217

23-
if tmpl, err = amber.Compile(raw, amber.DefaultOptions); err != nil {
24-
return
25-
}
26-
if err = tmpl.Execute(&buf, bind); err != nil {
27-
return
28-
}
29-
out = buf.String()
18+
if tmpl, err = amber.Compile(raw, amber.DefaultOptions); err != nil {
19+
return
20+
}
21+
if err = tmpl.Execute(&buf, binding); err != nil {
3022
return
3123
}
24+
out = buf.String()
25+
26+
return
3227
}
3328

3429
// Handlebars https://github.com/aymerick/raymond
35-
func Handlebars() func(raw string, bind interface{}) (out string, err error) {
36-
return func(raw string, bind interface{}) (out string, err error) {
37-
return handlebars.Render(raw, bind)
38-
}
30+
func Handlebars(raw string, data interface{}) (out string, err error) {
31+
return handlebars.Render(raw, data)
3932
}
4033

4134
// HTML https://golang.org/pkg/text/template/
42-
func HTML() func(raw string, bind interface{}) (out string, err error) {
43-
return func(raw string, bind interface{}) (out string, err error) {
44-
var buf bytes.Buffer
45-
var tmpl *template.Template
35+
func HTML(raw string, binding interface{}) (out string, err error) {
36+
var buf bytes.Buffer
37+
var tmpl *template.Template
4638

47-
if tmpl, err = template.New("").Parse(raw); err != nil {
48-
return
49-
}
50-
if err = tmpl.Execute(&buf, bind); err != nil {
51-
return
52-
}
53-
out = buf.String()
39+
if tmpl, err = template.New("").Parse(raw); err != nil {
40+
return
41+
}
42+
if err = tmpl.Execute(&buf, binding); err != nil {
5443
return
5544
}
45+
out = buf.String()
46+
return
5647
}
5748

5849
// Mustache https://github.com/hoisie/mustache
59-
func Mustache() func(raw string, bind interface{}) (out string, err error) {
60-
return func(raw string, bind interface{}) (out string, err error) {
61-
return mustache.Render(raw, bind)
62-
}
50+
func Mustache(raw string, binding interface{}) (out string, err error) {
51+
return mustache.Render(raw, binding)
6352
}
6453

6554
// Pug https://github.com/Joker/jade
66-
func Pug() func(raw string, bind interface{}) (out string, err error) {
67-
return func(raw string, bind interface{}) (out string, err error) {
68-
var buf bytes.Buffer
69-
var tmpl *template.Template
55+
func Pug(raw string, binding interface{}) (out string, err error) {
56+
var buf bytes.Buffer
57+
var tmpl *template.Template
7058

71-
if raw, err = pug.Parse("", []byte(raw)); err != nil {
72-
return
73-
}
74-
if tmpl, err = template.New("").Parse(raw); err != nil {
75-
return
76-
}
77-
if err = tmpl.Execute(&buf, bind); err != nil {
78-
return
79-
}
80-
out = buf.String()
59+
if raw, err = pug.Parse("", []byte(raw)); err != nil {
60+
return
61+
}
62+
if tmpl, err = template.New("").Parse(raw); err != nil {
8163
return
8264
}
65+
if err = tmpl.Execute(&buf, binding); err != nil {
66+
return
67+
}
68+
out = buf.String()
69+
return
70+
8371
}

0 commit comments

Comments
 (0)