Skip to content

Commit 6adc1de

Browse files
committed
More docs
1 parent 488f696 commit 6adc1de

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/phoenix_html.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule Phoenix.HTML do
132132
def raw(value) when is_binary(value) or is_list(value), do: {:safe, value}
133133

134134
@doc """
135-
Escapes the HTML entities in the given term, returning iodata.
135+
Escapes the HTML entities in the given term, returning safe iodata.
136136
137137
iex> html_escape("<hello>")
138138
{:safe, [[[] | "&lt;"], "hello" | "&gt;"]}
@@ -156,6 +156,11 @@ defmodule Phoenix.HTML do
156156
157157
Fails if the result is not safe. In such cases, you can
158158
invoke `html_escape/1` or `raw/1` accordingly before.
159+
160+
You can combine `html_escape/1` and `safe_to_string/1`
161+
to convert a data structure to a escaped string:
162+
163+
data |> html_escape() |> safe_to_string()
159164
"""
160165
@spec safe_to_string(safe) :: String.t()
161166
def safe_to_string({:safe, iodata}) do

0 commit comments

Comments
 (0)