Skip to content

Commit 6207ab0

Browse files
committed
v1.1.1
1 parent e597857 commit 6207ab0

File tree

1 file changed

+48
-36
lines changed

1 file changed

+48
-36
lines changed

main.go

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
package template
26

37
import (
@@ -11,61 +15,69 @@ import (
1115
)
1216

1317
// Amber https://github.com/eknkc/amber
14-
func Amber(raw string, binding interface{}) (out string, err error) {
15-
var buf bytes.Buffer
16-
var tmpl *template.Template
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
1722

18-
if tmpl, err = amber.Compile(raw, amber.DefaultOptions); err != nil {
19-
return
20-
}
21-
if err = tmpl.Execute(&buf, binding); err != nil {
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()
2230
return
2331
}
24-
out = buf.String()
25-
26-
return
2732
}
2833

2934
// Handlebars https://github.com/aymerick/raymond
30-
func Handlebars(raw string, data interface{}) (out string, err error) {
31-
return handlebars.Render(raw, data)
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+
}
3239
}
3340

3441
// HTML https://golang.org/pkg/text/template/
35-
func HTML(raw string, binding interface{}) (out string, err error) {
36-
var buf bytes.Buffer
37-
var tmpl *template.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
3846

39-
if tmpl, err = template.New("").Parse(raw); err != nil {
40-
return
41-
}
42-
if err = tmpl.Execute(&buf, binding); err != nil {
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()
4354
return
4455
}
45-
out = buf.String()
46-
return
4756
}
4857

4958
// Mustache https://github.com/hoisie/mustache
50-
func Mustache(raw string, binding interface{}) (out string, err error) {
51-
return mustache.Render(raw, binding)
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+
}
5263
}
5364

5465
// Pug https://github.com/Joker/jade
55-
func Pug(raw string, binding interface{}) (out string, err error) {
56-
var buf bytes.Buffer
57-
var tmpl *template.Template
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
5870

59-
if raw, err = pug.Parse("", []byte(raw)); err != nil {
60-
return
61-
}
62-
if tmpl, err = template.New("").Parse(raw); err != nil {
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()
6381
return
6482
}
65-
if err = tmpl.Execute(&buf, binding); err != nil {
66-
return
67-
}
68-
out = buf.String()
69-
return
70-
7183
}

0 commit comments

Comments
 (0)