Is it possible to access Plug.assign data in my phoenix views? I find myself writing long strings like
render("show.json",status: account_status, key_status: key_notification_status
Somehow I feel like I am able to extract Plug data from views or these are simply for processing of the plug pipeline?
The keyword list in
Phoenix.Controller.render/3 get merged into the assigns and are made available to the view in
render/2 as a map.
So if you wanted you could use
Plug.Conn.assign/3 like so:
|> assign(:status, account_status)
|> assign(:key_status, key_notification_status)
Then in your view, you could pull them out of the assigns as usual:
def render("show.json", assigns) do
I hope that answers your question.