Programming Phoenix LiveView B2.0: P168 "Render the Demographic Form"

A further clarification: When I move to the “Stateful components” section and run a compile with “iex -S mix”, the compile works. When I then try “mix phx.server” i get the same error as shown below. Interestingly, when I then went back to the stateless directory (where I had originally tried the “mix phx.server” and got the error below, I now got the same error when running “iex -S mix”

When attempting this, the server crashes with an error about @assign content not being available in the eex template. I have diffed all the files created following the book text with the ones in your code zip, but see no differences. Interestingly, the code in the “stateless_components” directory of the zip doesn’t compile either. I’ve copied the two sets of errors below.

I’ve moved on and I’m no longer trying to resolve this. Perhaps I have done something in error that I can’t see myself. But perhaps there is an error in the book’s code. Debugging this is beyond me.

Error when I attempt to compile the code in your zip file (downloaded today) under stateless_components:

== Compilation error in file lib/pento_web/live/product_live/show.ex ==
** (EEx.SyntaxError) /Users/alister/Programming/Practice/elixir/liveview/code/stateless_components/pento/lib/pento_web/live/product_live/show.html.leex:43:1: missing token ‘%>’
(eex 1.11.4) lib/eex/compiler.ex:37: EEx.Compiler.compile/2
(phoenix_live_view 0.15.1) expanding macro: Phoenix.LiveView.Renderer.before_compile/1
lib/pento_web/live/product_live/show.ex:9: PentoWeb.ProductLive.Show (module)
(elixir 1.11.4) lib/kernel/parallel_compiler.ex:314: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Error when I attempt to run the code I created following the text in B2.0:

[error] #PID<0.18693.0> running PentoWeb.Endpoint (connection #PID<0.18691.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /survey
** (exit) an exception was raised:
** (ArgumentError) assign @content not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:changed, :changeset, :demographic, :flash, :id, :socket, :user]

    (phoenix_live_view 0.15.4) lib/phoenix_live_view/engine.ex:877: Phoenix.LiveView.Engine.fetch_assign!/2
    lib/pento_web/live/demographic_live/form_component.html.leex:1: anonymous fn/2 in PentoWeb.DemographicLive.FormComponent.render/1
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
    (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:430: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/6
    (elixir 1.11.4) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:356: Phoenix.LiveView.Diff.traverse/6
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/diff.ex:130: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/static.ex:288: Phoenix.LiveView.Static.to_rendered_content_tag/4
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/static.ex:148: Phoenix.LiveView.Static.render/3
    (phoenix_live_view 0.15.4) lib/phoenix_live_view/controller.ex:35: Phoenix.LiveView.Controller.live_render/3
    (phoenix 1.5.8) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2
    (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.plug_builder_call/2
    (pento 0.1.0) lib/plug/debugger.ex:136: PentoWeb.Endpoint."call (overridable 3)"/2
    (pento 0.1.0) lib/pento_web/endpoint.ex:1: PentoWeb.Endpoint.call/2
    (phoenix 1.5.8) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
    (cowboy 2.8.0) /Users/alister/Programming/Practice/elixir/liveview/pento/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
    (cowboy 2.8.0) /Users/alister/Programming/Practice/elixir/liveview/pento/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3