2018-02-10 21:16:20 +00:00
|
|
|
package render
|
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"strings"
|
|
|
|
"time"
|
2018-04-29 19:56:37 +00:00
|
|
|
|
|
|
|
"github.com/kirsle/blog/internal/markdown"
|
2018-02-10 21:16:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Funcs is a global funcmap that the blog can hook its internal
|
|
|
|
// methods onto.
|
|
|
|
var Funcs = template.FuncMap{
|
|
|
|
"StringsJoin": strings.Join,
|
2018-04-29 19:56:37 +00:00
|
|
|
"NewlinesToSpace": func(text string) string {
|
|
|
|
return strings.Replace(
|
|
|
|
strings.Replace(text, "\n", " ", -1),
|
|
|
|
"\r", "", -1,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
"Now": time.Now,
|
|
|
|
"TrustedMarkdown": func(text string) template.HTML {
|
|
|
|
return template.HTML(markdown.RenderTrustedMarkdown(text))
|
|
|
|
},
|
2018-02-10 21:16:20 +00:00
|
|
|
}
|