mirror of
https://github.com/thegeeklab/wp-matrix.git
synced 2024-11-09 18:10:39 +00:00
21 lines
507 B
Go
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 <em>cool</em> website</a>
|
|
}
|