Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

アクションごとの設定

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

su_mi
mail.sumimaru@gmail.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away