mirror of
https://github.com/thegeeklab/drone-matrix.git
synced 2024-11-16 15:40: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>
|
|
}
|