···11-# houdini
11+# Houdini's publicist
2233-[](https://hex.pm/packages/houdini)
44-[](https://hexdocs.pm/houdini/)
33+A fork of [houdini](https://github.com/giacomocavalieri/houdini) that adds a function specifically for escaping attributes but only adds quotes when the string isn't alphanumeric or one of `-_./:`. Why would you want this? Well to have a slightly smaller html file size. Probably not worth it! 🤷
5466-🪄 Fast HTML escaping
55+This isn't added to Hex, so you'll have to add it as a git dependency in your `gleam.toml`:
7688-```sh
99-gleam add houdini@1
107```
1111-1212-Use `houdini.escape` to escape any string to be safely used inside an HTML
1313-document:
88+houdinis_publicist = { git = "https://github.com/bentomas/houdinis_publicist.git", ref = "595cdc46" }
99+```
14101515-```gleam
1616-import houdini
1111+It automatically adds the quotes for you if they are necessary:
17121818-pub fn main() -> Nil {
1919- assert houdini.escape("wibble & wobble") == "wibble & wobble"
2020- assert houdini.escape("wibble > wobble") == "wibble > wobble"
2121-}
2213```
1414+houdinis_publicist.escape_attribute("abcd")
1515+// => "abcd"
1616+1717+houdinis_publicist.escape_attribute("ab_cd")
1818+// => "ab_cd"
1919+2020+houdinis_publicist.escape_attribute("ab cd")
2121+// => "\"ab cd\""
2222+2323+houdinis_publicist.escape_attribute("a\"")
2424+// => "\"a"\""