I know there are some similar questions but I couldn’t find the answer to my question though I think I’ve already seen it somewhere… Sorry in advance if this is duplicated.
I’ve this two templates:
lib/web/templates/session/new.html.drab
:
<%= render __MODULE__, "_login_form.html", conn: @conn, loading: false %>
lib/web/templates/session/_login_form.html.drab
:
<%= if @loading do %>
<%= gettext "Logging in..." %>
<% else %>
<%= gettext "Login" %>
<% end %>
With the above setup, I get the following error:
[error] Drab Handler failed with the following exception:
** (ArgumentError) assign @loading not found in Drab 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:
[]
However if in the _login_form.html.drab
template I add:
<%= @loading %>
It starts working… What’s the difference here between using like <%= @loading %>
or <%= if @loading, do: "Loading" %>
regarding Drab?
Thanks!