Sanjibukai
Hello everybody,
I’m trying to figure out where the default “app.html.eex” file is defined in all the pipeline.
The better I managed to find is the following explanation on the Phoenix Controller part of the documentation:
defmodule MyAppWeb.UserController do use Phoenix.Controller def show(conn, _params) do render(conn, "show.html", message: "Hello") end endwill render the “show.html” template inside an “app.html” template specified in
MyAppWeb.LayoutView.
However I wasn’t able to find the exact part in the source code where this is happening.
I tried by renaming the file (for example ap.html.eex which it gives me an error) to follow the stack trace to find where the default layout is applied.
I also tried to figure out where the app.html.eex template is injected by putting many IO.inpsect(template) all over the source code of Phoenix around the renders functions where things seem to happen.. But without success..
I also read in Chris’ book (Programming Phoenix) the following (on page 57):
When you call render in your controller, you’re actu-
ally rendering with the :layout option set by default. This allows you to render
the view and template for your controller action in the layout with a plain
render function call. No magic is happening here.
To be honest it is like magic for me..
Any details will be appreciated!
Thank you..
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Kurisu
I found this in
deps/phoenix/lib/phoenix/controller.ex__using__macro definition:And in the same file (there is
LayoutViewat the last line ):Sanjibukai
Thanks I didn’t think to look at
__using__and also didn’t think to look for the atom:app..Btw, does anyone know the reason behind the double underscore formatting for
__layout__and__view__?I got that for
__MODULE__it’s a language construct for identifying the current module, but what about using this format for defined functions?Kurisu
This is in Elixir naming convention: