EExHTML
Extension to Embedded Elixir (EEx), that allows content to be safely embedded into HTML.
iex> import EEx.HTML
iex> title = "EEx Rocks!"
iex> content = ~E"<h1><%= title %></h1>"
%EExHTML.Safe{data: [[[[] | "<h1>"], "EEx Rocks!"] | "</h1>"]}
iex> "#{content}"
"<h1>EEx Rocks!</h1>"
iex> title = "<script>"
iex> content = ~E"<h1><%= title %></h1>"
%EExHTML.Safe{data: [[[[] | "<h1>"], [[[] | "<"], "script" | ">"]] | "</h1>"]}
iex> "#{content}"
"<h1><script></h1>"
Works to integrate with the rest of EEx
by implementing a HTML specific engine.
It is extensible for custom data types through the EExHTML.Safe
protocol.
The library handles
- Auto escaping
- Setting JavaScript variables