1. How to specify the layout when render() in controllers
There is an option in render/3 method, source
In the below example, I did specify the layout, the layout will be located at @conn.assigns[:layout], so as :id
The directory which locate layout look like:
2. Setup a default layout for all method within a controller
We have to use plug :put_layout.
3. Get advanced from PLUG.
Because of using plug, we can also specify the defaul layout in router. In route.ex we can define an extra pipeline.
And then, within scope, add the pipeline via pipe_through. Here is an example.