Hello Guys, Elixir/phoenix have some helper to concat sigils?
What do you think about this feature?
Code:
defmodule Teste do
import Phoenix.HTML
def sigil_concat_1() do
~E"""
<div class="col-lg-4">
<%= "Hello" %>
</div>
"""
end
def sigil_concat_2() do
world = "World"
~E"""
<div class="col-lg-4">
<%= world %>!
</div>
"""
end
end
Test:
Interactive Elixir (1.5.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> s1 = Teste.sigil_concat_1
{:safe, [[["" | "<div class=\"col-lg-4\">\n "] | "Hello"] | "\n</div>\n"]}
iex(2)> s2 = Teste.sigil_concat_2
{:safe, [[["" | "<div class=\"col-lg-4\">\n "] | "World"] | "!\n</div>\n"]}
iex(3)> s1 <> s2
** (ArgumentError) argument error
iex(3)> s1 ++ s2
** (ArgumentError) argument error
:erlang.++({:safe, [[["" | "<div class=\"col-lg-4\">\n "] | "Hello"] | "\n</div>\n"]}, {:safe, [[["" | "<div class=\"col-lg-4\">\n "] | "World"] | "!\n</div>\n"]})
iex(3)>