mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Add safeUrl
; disable safeHtmlAttr
; rename safeCSS
to safeCss
- Add `safeUrl` template function (Fixes #347) - Add TestSafeUrl() fashioned after @tatsushid great examples - Disable `safeHtmlAttr` pending further discussions on its other use cases because `safeUrl` is a cleaner solution to #347. (There are also `safeJs` and `safeJsStr` that we could implement if there are legitimate demands for them.) - Rename `safeCSS` to `safeCss` (to follow the convention of `safeHtml`) - Add/expand documentation on `safeHtml`, `safeCss` and `safeUrl`
This commit is contained in:
@@ -910,14 +910,20 @@ func SafeHtml(text string) template.HTML {
|
||||
return template.HTML(text)
|
||||
}
|
||||
|
||||
// "safeHtmlAttr" is currently disabled, pending further discussion
|
||||
// on its use case. 2015-01-19
|
||||
func SafeHtmlAttr(text string) template.HTMLAttr {
|
||||
return template.HTMLAttr(text)
|
||||
}
|
||||
|
||||
func SafeCSS(text string) template.CSS {
|
||||
func SafeCss(text string) template.CSS {
|
||||
return template.CSS(text)
|
||||
}
|
||||
|
||||
func SafeUrl(text string) template.URL {
|
||||
return template.URL(text)
|
||||
}
|
||||
|
||||
func doArithmetic(a, b interface{}, op rune) (interface{}, error) {
|
||||
av := reflect.ValueOf(a)
|
||||
bv := reflect.ValueOf(b)
|
||||
@@ -1251,8 +1257,8 @@ func init() {
|
||||
"isset": IsSet,
|
||||
"echoParam": ReturnWhenSet,
|
||||
"safeHtml": SafeHtml,
|
||||
"safeHtmlAttr": SafeHtmlAttr,
|
||||
"safeCSS": SafeCSS,
|
||||
"safeCss": SafeCss,
|
||||
"safeUrl": SafeUrl,
|
||||
"markdownify": Markdownify,
|
||||
"first": First,
|
||||
"where": Where,
|
||||
|
Reference in New Issue
Block a user