Note to self - trying stuff out …
some_phoenix_project$ iex -S mix
Erlang/OTP 21 [erts-10.1.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> import Phoenix.HTML
Phoenix.HTML
iex(2)> import Phoenix.HTML.Form
Phoenix.HTML.Form
iex(3)> builder = fn select_for ->
...(3)> ~E"""
...(3)> <div class="flex">
...(3)> <%= select_for.(:day, [class: "xyz"]) %>
...(3)> <%= select_for.(:month, [class: "abc"]) %>
...(3)> <%= select_for.(:year, [class: "def"]) %>
...(3)> </div>
...(3)> """
...(3)> end
#Function<6.128620087/1 in :erl_eval.expr/5>
iex(4)> content = ~E"""
...(4)> <%= date_select :user, :born_at,
...(4)> builder: builder,
...(4)> year: [options: 2018..2018],
...(4)> month: [options: 12..12],
...(4)> day: [options: 13..13]
...(4)> %>
...(4)> """
{:safe,
[
[
"",
[
[
[
[
[
["" | "<div class=\"flex\">\n "],
60,
"select",
[
[32, "class", 61, 34, "xyz", 34],
[32, "id", 61, 34, "user_born_at_day", 34],
[32, "name", 61, 34, "user[born_at][day]", 34]
],
62,
[
"",
60,
"option",
[[32, "value", 61, 34, "13", 34]],
62,
"13",
60,
47,
"option",
62
],
60,
47,
"select",
62
] |
"\n "
],
60,
"select",
[
[32, "class", 61, 34, "abc", 34],
[32, "id", 61, 34, "user_born_at_month", 34],
[32, "name", 61, 34, "user[born_at][month]", 34]
],
62,
[
"",
60,
"option",
[[32, "value", 61, 34, "12", 34]],
62,
"12",
60,
47,
"option",
62
],
60,
47,
"select",
62
] |
"\n "
],
60,
"select",
[
[32, "class", 61, 34, "def", 34],
[32, "id", 61, 34, "user_born_at_year", 34],
[32, "name", 61, 34, "user[born_at][year]", 34]
],
62,
[
"",
60,
"option",
[[32, "value", 61, 34, "2018", 34]],
62,
"2018",
60,
47,
"option",
62
],
60,
47,
"select",
62
] |
"\n</div>\n"
] |
"\n"
]}
iex(5)> safe_to_string(content)
"<div class=\"flex\">\n <select class=\"xyz\" id=\"user_born_at_day\" name=\"user[born_at][day]\"><option value=\"13\">13</option></select>\n <select class=\"abc\" id=\"user_born_at_month\" name=\"user[born_at][month]\"><option value=\"12\">12</option></select>\n <select class=\"def\" id=\"user_born_at_year\" name=\"user[born_at][year]\"><option value=\"2018\">2018</option></select>\n</div>\n\n"
iex(6)>