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…

https://hexdocs.pm/phoenix/Phoenix.Controller.html#render/2

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

Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
ejpcmac
I have discovered Nix last month and I am currently on my way to migrating to it—both on macOS at home and the full NixOS distrubution at...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31107 143
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
hazardfn
I suppose this question is effectively hackney vs. ibrowse but we are at a point in our project where we have to make a choice between th...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
acrolink
How does the two languages compare when it comes to server side application development? Any experiences or ideas? Thank you.
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30840 112
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement