Merge pull request #347 from odiel/master
Adding template functions to generate JS and CSS tags
Showing
2 changed files
with
21 additions
and
0 deletions
| ... | @@ -34,6 +34,8 @@ func init() { | ... | @@ -34,6 +34,8 @@ func init() { |
| 34 | beegoTplFuncMap["htmlquote"] = Htmlquote | 34 | beegoTplFuncMap["htmlquote"] = Htmlquote |
| 35 | beegoTplFuncMap["htmlunquote"] = Htmlunquote | 35 | beegoTplFuncMap["htmlunquote"] = Htmlunquote |
| 36 | beegoTplFuncMap["renderform"] = RenderForm | 36 | beegoTplFuncMap["renderform"] = RenderForm |
| 37 | beegoTplFuncMap["assets_js"] = AssetsJs | ||
| 38 | beegoTplFuncMap["assets_css"] = AssetsCss | ||
| 37 | 39 | ||
| 38 | // go1.2 added template funcs | 40 | // go1.2 added template funcs |
| 39 | // Comparisons | 41 | // Comparisons | ... | ... |
| ... | @@ -388,3 +388,22 @@ func GetRandomString(n int) string { | ... | @@ -388,3 +388,22 @@ func GetRandomString(n int) string { |
| 388 | func UrlFor(endpoint string, values ...string) string { | 388 | func UrlFor(endpoint string, values ...string) string { |
| 389 | return BeeApp.UrlFor(endpoint, values...) | 389 | return BeeApp.UrlFor(endpoint, values...) |
| 390 | } | 390 | } |
| 391 | |||
| 392 | |||
| 393 | //This can be changed to a better name | ||
| 394 | func AssetsJs(src string) template.HTML { | ||
| 395 | text := string(src) | ||
| 396 | |||
| 397 | text = "<script src=\""+src+"\"></script>" | ||
| 398 | |||
| 399 | return template.HTML(text) | ||
| 400 | } | ||
| 401 | |||
| 402 | //This can be changed to a better name | ||
| 403 | func AssetsCss(src string) template.HTML { | ||
| 404 | text := string(src) | ||
| 405 | |||
| 406 | text = "<link href=\""+src+"\" rel=\"stylesheet\" />" | ||
| 407 | |||
| 408 | return template.HTML(text) | ||
| 409 | } | ... | ... |
-
Please register or sign in to post a comment