forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.go
38 lines (31 loc) · 781 Bytes
/
string.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
package render
import (
"io"
"github.com/aymerick/raymond"
)
type stringRenderer struct {
body string
}
func (s stringRenderer) ContentType() string {
return "text/plain"
}
func (s stringRenderer) Render(w io.Writer, data Data) error {
b, err := raymond.Render(s.body, data)
if err != nil {
return err
}
_, err = w.Write([]byte(b))
return err
}
// String renderer that will run the string through
// the github.com/aymerick/raymond package and return
// "text/plain" as the content type.
func String(s string) Renderer {
return stringRenderer{body: s}
}
// String renderer that will run the string through
// the github.com/aymerick/raymond package and return
// "text/plain" as the content type.
func (e *Engine) String(s string) Renderer {
return String(s)
}