@@ -45,39 +45,36 @@ defimpl Phoenix.HTML.Safe, for: DateTime do
4545end
4646
4747defimpl Phoenix.HTML.Safe , for: List do
48- def to_iodata ( [ h | t ] ) do
49- [ to_iodata ( h ) | to_iodata ( t ) ]
50- end
48+ def to_iodata ( list ) , do: recur ( list )
5149
52- def to_iodata ( [ ] ) do
53- [ ]
54- end
50+ defp recur ( [ h | t ] ) , do: [ recur ( h ) | recur ( t ) ]
51+ defp recur ( [ ] ) , do: [ ]
5552
56- def to_iodata ( ?< ) , do: "<"
57- def to_iodata ( ?> ) , do: ">"
58- def to_iodata ( ?& ) , do: "&"
59- def to_iodata ( ?" ) , do: """
60- def to_iodata ( ?' ) , do: "'"
53+ defp recur ( ?< ) , do: "<"
54+ defp recur ( ?> ) , do: ">"
55+ defp recur ( ?& ) , do: "&"
56+ defp recur ( ?" ) , do: """
57+ defp recur ( ?' ) , do: "'"
6158
62- def to_iodata ( h ) when is_integer ( h ) and h <= 255 do
59+ defp recur ( h ) when is_integer ( h ) and h <= 255 do
6360 h
6461 end
6562
66- def to_iodata ( h ) when is_integer ( h ) do
63+ defp recur ( h ) when is_integer ( h ) do
6764 raise ArgumentError ,
6865 "lists in Phoenix.HTML templates only support iodata, and not chardata. Integers may only represent bytes. " <>
6966 "It's likely you meant to pass a string with double quotes instead of a char list with single quotes."
7067 end
7168
72- def to_iodata ( h ) when is_binary ( h ) do
69+ defp recur ( h ) when is_binary ( h ) do
7370 Phoenix.HTML.Engine . html_escape ( h )
7471 end
7572
76- def to_iodata ( { :safe , data } ) do
73+ defp recur ( { :safe , data } ) do
7774 data
7875 end
7976
80- def to_iodata ( other ) do
77+ defp recur ( other ) do
8178 raise ArgumentError ,
8279 "lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, " <>
8380 "got invalid entry: #{ inspect ( other ) } "
0 commit comments