Skip to content

Instantly share code, notes, and snippets.

@techslides
Last active September 28, 2015 10:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save techslides/8760361 to your computer and use it in GitHub Desktop.
Save techslides/8760361 to your computer and use it in GitHub Desktop.
Martini Render FuncMap Function to unescape string into HTML and time converting
//needs import ("time")
m.Use(render.Renderer(render.Options{
Directory: "templates",
Layout: "layout",
Funcs: []template.FuncMap{
{
"formatTime": func(args ...interface{}) string {
t1 := time.Unix(args[0].(int64), 0)
return t1.Format(time.Stamp)
},
"unescaped": func(args ...interface{}) template.HTML {
r eturn template.HTML(args[0].(string))
},
},
},
}))
@techslides
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment