LoginSignup
3

More than 5 years have passed since last update.

elixir on phoenix layoutのテンプレートを変更する

Posted at

アクションごとの設定

defmodule Sample.PageController do
  use Sample.Web, :controller

  def index(conn, _params) do
    conn
    |> put_layout("admin.html")
    |> render("index.html")
  end
end

put_layoutにfasleを渡すとレイアウトを使用しなくなる。

Routerで設定


defmodule Sample.Router do
  use Sample.Web, :router

  ・・・・・

  # 使用するレイアウトの指定
  pipeline :admin_layout do
    plug :put_layout, {Sample.LayoutView, :admin}
  end

  scope "/", Sample do
    pipe_through [:browser, :admin_layout]

    get "/", PageController, :index
  end

  ・・・・・

end

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3