Documentation
¶
Overview ¶
Package escape provides Twig-compatible escape functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSS ¶
CSS provides a Twig-compatible CSS escaper.
Example ¶
package main import ( "fmt" "bitbucket.org/ticketshopdev/stick/twig/escape" ) func main() { input := "some \" bad content" fmt.Printf("div:after { content: \"%s\"; }", escape.CSS(input)) }
Output: div:after { content: "some\0020\0022\0020bad\0020content"; }
func HTML ¶
HTML provides a Twig-compatible HTML escape function.
Example ¶
package main import ( "fmt" "bitbucket.org/ticketshopdev/stick/twig/escape" ) func main() { input := "Very <unsafe> \"string & stuff'" fmt.Print(escape.HTML(input)) }
Output: Very <unsafe> "string & stuff'
func HTMLAttribute ¶
HTMLAttribute provides a Twig-compatible escaper for HTML attributes.
Example ¶
package main import ( "fmt" "bitbucket.org/ticketshopdev/stick/twig/escape" ) func main() { input := "a bad\">\battribute<נש" fmt.Printf("<a href=\"%s\">A link</a>", escape.HTMLAttribute(input)) }
Output: <a href="a bad">�attribute<נש">A link</a>
func JS ¶
JS provides a Twig-compatible javascript escaper.
Example ¶
package main import ( "fmt" "bitbucket.org/ticketshopdev/stick/twig/escape" ) func main() { input := "some \"' bad javascript" fmt.Printf("var test = \"%s\";", escape.JS(input)) }
Output: var test = "some\u0020\u0022\u0027\u0020bad\u0020javascript";
func URLQueryParam ¶
URLQueryParam provides Twig-compatible query string escaper.
Example ¶
package main import ( "fmt" "bitbucket.org/ticketshopdev/stick/twig/escape" ) func main() { input := "מיין מאמעם" fmt.Printf("?who=%s", escape.URLQueryParam(input)) }
Output: ?who=%D7%9E%D7%99%D7%99%D7%9F%20%D7%9E%D7%90%D7%9E%D7%A2%D7%9D
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.