Phoenix.View.render_one
You're seeing just the function
render_one
, go back to Phoenix.View module for more information.
Renders a single item if not nil.
The following:
render_one user, UserView, "show.html"
is roughly equivalent to:
if user != nil do
render(UserView, "show.html", user: user)
end
The underlying user is passed to the view and template as
:user
, which is inflected from the view name. The name
of the key in assigns can be customized with the :as
option:
render_one user, UserView, "show.html", as: :data
is roughly equivalent to:
if user != nil do
render(UserView, "show.html", data: user)
end