wktdev
Where does the render() function come from?
In the Phoenix code below where is the render() function being referenced from? Where is its actual declaration?
defmodule AppxWeb.HelloController do
use AppxWeb, :controller
def world(conn, _params) do
render(conn, "world.html")
end
end
Most Liked
c4710n
To supplement more details…
-
use AppxWeb, :controllercalls theAppxWeb.controller/0function viaAppxWeb.__using__/1macro. -
AppxWeb.controller/0importsPhoenix.Controller.
Before using Phoenix, learning some basic Elixir is important.
kokolegorille
It is in the Phoenix controller code…
Sanjibukai
I’m not 100% sure but afaik there’s no “magic” in Phoenix/Elixir, I mean there is no implicit “code injection”.
So the only place where any function that you are using without a Module name (like render here) could only reside in that module itself (in def or defp) or in any module you are explicitly importing or useing. The only exception being functions from the Kernel module where they are imported automatically.
Even aliasing modules still need to call functions with the aliased module name…
I think that this can help better understand how things are tied together in Elixir projects.
The explicitness of Elixir make it very clear. Also this reminds me a recent discussion here in the forum about implicitness vs explicitness… (will update with the link, currently on mobile)







