mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Added safeHtml template function
This commit is contained in:
@@ -78,6 +78,10 @@ func ReturnWhenSet(a interface{}, index int) interface{} {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SafeHtml(text string) template.HTML {
|
||||||
|
return template.HTML(text)
|
||||||
|
}
|
||||||
|
|
||||||
type Template interface {
|
type Template interface {
|
||||||
ExecuteTemplate(wr io.Writer, name string, data interface{}) error
|
ExecuteTemplate(wr io.Writer, name string, data interface{}) error
|
||||||
Lookup(name string) *template.Template
|
Lookup(name string) *template.Template
|
||||||
@@ -108,6 +112,7 @@ func NewTemplate() Template {
|
|||||||
"gt": Gt,
|
"gt": Gt,
|
||||||
"isset": IsSet,
|
"isset": IsSet,
|
||||||
"echoParam": ReturnWhenSet,
|
"echoParam": ReturnWhenSet,
|
||||||
|
"safeHtml": SafeHtml,
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.Funcs(funcMap)
|
templates.Funcs(funcMap)
|
||||||
|
Reference in New Issue
Block a user