Packages

Lib for elixir

Current section

Files

Jump to
gulib lib core string html.ex
Raw

lib/core/string/html.ex

defmodule Gulib.String.HTML do
def unescape(nil), do: ""
def unescape(text) do
text
|> String.replace("&", "&")
|> String.replace("&lt;", "<")
|> String.replace("&gt;", ">")
|> String.replace("&quot;", "\"")
|> String.replace("&apos;", "'")
end
def escape(nil), do: ""
def escape(text) do
text
|> String.replace("&", "&amp;")
|> String.replace("<", "&lt;")
|> String.replace(">", "&gt;")
|> String.replace("\"", "&quot;")
|> String.replace("'", "&apos;")
end
end