florish

florish

Problems with HEEx on upgrading a LiveView-less project from Phoenix 1.5 to 1.6

I’m running into some problems while upgrading a Phoenix project from 1.5 to 1.6. Specifically, my question is: why is phoenix_live_view needed as an extra dependency when you only need HEEx and not LiveView?

Context: the application is a small project originally built in Phoenix 1.4 and later upgraded to Phoenix 1.5. It is a “traditional” application with non-LiveView HTML pages rendered using EEx templates.

As suggested in the Phoenix 1.5.x to 1.6 upgrade instructions, I’d like to replace all my EEx (.html.eex files and ~E sigils) with HEEx (.html.heex and ~H sigils).

This step is marked as optional, but if I don’t do this after upgrading phoenix_html to a 3.x version (per the Update your deps instructions), I get warnings like this:

warning: Phoenix.HTML.sigil_E/2 is deprecated. use the ~H sigil instead

Once I replace ~E with ~H, however, I’m starting to get compilation errors:

== Compilation error in file lib/example_web/views/example_view.ex ==
** (CompileError) lib/example_web/views/example_view.ex:24: undefined function sigil_H/2

After some research, I found that sigil_H/2 is defined inside the Phoenix.LiveView.Helpers module. After adding phoenix_live_view to my dependencies and adding import Phoenix.LiveView.Helpers to my views, the compiler errors indeed disappear.

All in all this leaves me with a working Phoenix 1.6 project that does not need LiveView at all, but does need the phoenix_live_view package only for bare HEEx support. This somehow feels weird, as it seems to go against the idea of HEEx to be a (LiveView-independent) replacement for both EEx and LEEx.

And with that I’m getting back to my original question: has LiveView (phoenix_live_view) indeed become a necessary dependency for any Phoenix 1.6+ project that needs HEEx-based HTML rendering? Thanks!

Marked As Solved

cmo

cmo

If I remember correctly, it was too hard or too much work to split HEEX out of LiveView and making LV a dependency was the compromise.

Also Liked

sodapopcan

sodapopcan

Up to you, but a post from three days ago may give you a bit of insight there. Hard to tell but seems like a weak maybe that it’ll ever happen.

cmo

cmo

I think I heard it on this Thinking Elixir podcast :man_shrugging:

The info you figured out is in the upgrade guide & it’s comments.

ericlathrop

ericlathrop

That’s annoying. I’m going to keep on using ~E until it’s removed, and hopefully by then HEEX will be split out of LiveView.

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29703 241
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement