diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/templates/helper.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 235b649547..821ff6c9c7 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -66,6 +66,7 @@ func NewFuncMap() []template.FuncMap { }, "AvatarLink": base.AvatarLink, "Safe": Safe, + "SafeJS": SafeJS, "Sanitize": bluemonday.UGCPolicy().Sanitize, "Str2html": Str2html, "TimeSince": base.TimeSince, @@ -162,6 +163,11 @@ func Safe(raw string) template.HTML { return template.HTML(raw) } +// SafeJS renders raw as JS +func SafeJS(raw string) template.JS { + return template.JS(raw) +} + // Str2html render Markdown text to HTML func Str2html(raw string) template.HTML { return template.HTML(markdown.Sanitize(raw)) |