We have a working system with LiveView in place that works on 0.16.4 and I wanted to upgrade to 0.17 today. We already migrated all the old leex to heex and that was also working prior to 0.17. But now after upgrading some methods are rendered as undefined
. The are functions called from within a .heex
template and defined inside a regular module (a View module).
For instance, this parent.heex
has:
<div>
<%= MyView.render_custom_label(:question, detail) %>
</div>
Previously this rendered a <span>
tag with a class and some text. Now it renders undefined. This is the method being called:
def render_custom_label(type, detail) do
class = get_class(type) # returns some string
assigns = %{class: class, detail: detail}
~H"""
<span class={@class}><%= @detail %></span>
"""
end
Although I appreciate this not being the best way of rendering small portions of markup (should use components?), what I really want to understand is why this is rendering undefined
.
PS: we are still searching how to properly integrate LiveView in a more structural way, but we are doing it gradually. We have been building this production app in Elixir for over three years so we need to take small steps when integrating new things.