Last active
September 28, 2015 10:37
-
-
Save techslides/8760361 to your computer and use it in GitHub Desktop.
Martini Render FuncMap Function to unescape string into HTML and time converting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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)) | |
}, | |
}, | |
}, | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Learn more about this code here: http://techslides.com/simple-app-with-go-martini-gorp-and-mysql/