When creating a live view module without a matching template or render/1 clause and compiling, the following error is being raised (as expected):
[error] #PID<0.4824.0> running DropdownWeb.Endpoint (connection #PID<0.4799.0>, stream id 3) terminated
Server: localhost:5000 (http)
Request: GET /
** (exit) an exception was raised:
** (RuntimeError) render/1 was not implemented for DropdownWeb.PageLive.DateRangeDropdown.
Make sure to either explicitly define a render/1 clause with a LiveView template:
def render(assigns) do
~L"""
...
"""
end
Or create a file at "lib/dropdown_web/live/date_range_dropdown.html.leex" with the LiveView template.
But it also doesn’t go away after adding such a file and only goes away mix compile --force.
I’ve noticed this too but haven’t tried to reproduce it. Are you able to reproduce it 100%? I think it might also go away if you restart the Phoenix server (although I haven’t tested enough to be sure).
both the problem and the solutions are still the case with Mix 1.12.3 (compiled with Erlang/OTP 24) - in my application configured to use liveview and working as expected for files which are created in tandem (.html.heex + .ex ), if an .ex file exists without a corresponding html.heex file when you first run mix phx.server, it doesn’t respond by adding .html.heex extensions to your template file. (throws error render/1 was not implemented for…). You need to run mix compile --force after either altering the extension or adding the template file if you didn’t have one and don’t have a render call in the corresponding .ex file.
A related design change which threw me off: I was working on a new project with mix 1.12.3 after having used whatever was out around march 2021, and the html.leex extension doesn’t seem to work anymore. Digging about, check out Live layouts — Phoenix LiveView v0.17.7 - there’s a little nugget of information right after the first formatted box on this page that is good to know - it looks like going forwards, the .heex extension is what the phoenix team is going to be expecting appended to templates (.html.heex)