I’m trying to nest EEX templates. I’d like this approach to be able to pass HTML as a parameter to a render function. To make this happen I tried to use the ~E
sigil from Phoenix.HTML
.
Given the following code I get an error:
<%= render(AcmeAdmin.PartialView, "_card.html", content: ~E"""
<table>
<tr>
<th><%= "Name" |> gettext %></th>
</tr>
</table>
""") %>
** (TokenMissingError) lib/acme_admin/templates/partial/foo.html.eex:4: missing terminator: """ (for heredoc starting at line 1)
(eex) lib/eex/compiler.ex:45: EEx.Compiler.generate_buffer/4
(phoenix) lib/phoenix/template.ex:349: Phoenix.Template.compile/3
(phoenix) lib/phoenix/template.ex:160: anonymous fn/4 in Phoenix.Template."MACRO-__before_compile__"/2
(elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) expanding macro: Phoenix.Template.__before_compile__/1
lib/acme_admin/views/partial_view.ex:1: AcmeAdmin.PartialView (module)
(elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
I tried to escape the inner eex block with double %%.
How can this be implemented?