wktdev

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

c4710n

To supplement more details…

  1. use AppxWeb, :controller calls the AppxWeb.controller/0 function via AppxWeb.__using__/1 macro.
  2. AppxWeb.controller/0 imports Phoenix.Controller.

Before using Phoenix, learning some basic Elixir is important.

kokolegorille

kokolegorille

It is in the Phoenix controller code…

Sanjibukai

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)

Where Next?

Popular in Discussions Top

AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18584 126
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement