0
0
mirror of https://github.com/thegeeklab/wp-matrix.git synced 2024-11-09 18:10:39 +00:00
wp-matrix/vendor/github.com/aymerick/raymond/escape_test.go
2018-01-08 09:54:13 +01:00

21 lines
507 B
Go

package raymond
import "fmt"
func ExampleEscape() {
tpl := MustParse("{{link url text}}")
tpl.RegisterHelper("link", func(url string, text string) SafeString {
return SafeString("<a href='" + Escape(url) + "'>" + Escape(text) + "</a>")
})
ctx := map[string]string{
"url": "http://www.aymerick.com/",
"text": "This is a <em>cool</em> website",
}
result := tpl.MustExec(ctx)
fmt.Print(result)
// Output: <a href='http://www.aymerick.com/'>This is a &lt;em&gt;cool&lt;/em&gt; website</a>
}