Embed_templates 1.7 error with list

I notice a difference in using

embed_templates from a controller and an explicit component definition

from a controller and embed_template

  • new.html.heex
  • sub.html.heex

in new.html.heex with @comps a list of maps

<sub comps={@comps}/>

this fails with

lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry

if instead

<Component.sub comps={@comps} />

it works as usual, with the exact same component defined in a regular component file

how do you alias for embedded templates ? putting the alias in the new view module does not work

defmodule AppWeb.catHTMl do

embed_templates "cat_html/*"

alias AppWeb.MyModule <- does not work for embedded template


This markup is not calling the function component defined by the function sub/1, it’s creating a “sub” HTML tag. Interpolation of the comps attribute fails because it can’t be interpolated as valid HTML, as the message says.

To render a function component defined by the local function sub/1, you have add a dot:

<.sub comps={@comps} />