-
Notifications
You must be signed in to change notification settings - Fork 9
Description
As I work though my first custom page on a project, I'm suspecting that every page will need controller customization. This is in contrast to resource controllers that controller customization might be the exception.
I don't think it makes sense to create some fancy API for handling controller customization for pages when we already have a controller generated. It makes more sense to work in the page controller directly.
I propose that we generate a page controller for each page (named after the page name) and generate the default action in the the controller. The default implementation of the action can be the same as the current page action in Talon.PageController. We can include some helpers in the Talon.PageController using block...
The way I'm going to handle customization in my project right now is
defmodule UcxUcc.Web.TalonPageController do
use UcxUcc.Web, :controller
use Talon.PageController, concern: UcxUcc.Admin
plug Talon.Plug.LoadConcern, concern: UcxUcc.Admin, web_namespace: Web
plug Talon.Plug.Theme
plug Talon.Plug.Layout, layout: {Elixir.UcxUcc.Admin.AdminLte.Web.LayoutView, "app.html"}
plug Talon.Plug.View
def page(conn, params) do
handle_page conn, params, Map.get(params, "page", "info")
end
def handle_page(conn, params, "info") do
# My customization here
render(conn, "info.html")
end
# render default page
def handle_page(conn, params, page) do
render(conn, "#{page}.html")
end
end