Function Plugs and Module Plugs
These are functions that get a Plug.Conn
struct and give a Plug.Conn
struct.
How to Create Function Plugs
- Create new Module “test” with
import Plug.conn
- Write the function
def function_plug(conn, _options)
that usesassign()
- In the controller, use that Function Plug Module by importing it
- Call function
plug :blah
- Render it in the view with
<%= @conn.assigns[:blah] %>
Function Plugs take 2 items: conn and options. If data is available in conn
then use function plugs.
Module Plugs
These need to be initialized.