onelixir
Hello,
I am studying《Build Your Own Web Framework in Elixir》, In about chapter 7 when I follow the book write code like this:
def render(view_module, conn, file, assigns) do
functions = view_module.__info__(:functions)
contents =
file
|> html_file_path()
|> EEx.eval_file([assigns: assigns], functions: [{view_module, functions}])
Controller.render(conn, :html, contents)
end
I get a warning: warning: :functions option in eval is deprecated, and I checked the official document EEx.html#module-options, which doesn’t have functions options, I also check Elixir version before v1.10.0, also don’t have this option, my question is:
- In
EEx.eval_fileif I want to pass afunctionsoption, what should I do? - Where does the
functionsoption come from at the beginning? seems the document never wrote about this option, so how does the author of this book know this?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
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
- #ai
- #elixirconf-us
- #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 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
One can always look at the code, not just the documentation. Though it it hadn’t been documented it likely wasn’t supposed to be used.
onelixir
I followed your suggestion, find out the source code here: do_eval, after that I cannot go further, It is not easy for me.
Also, nothing mentioned cannot use
:functionsas an option.LostKobrakai
This part is in the parser itself:
https://github.com/elixir-lang/elixir/blob/main/lib/elixir/src/elixir.erl#L292-L298
onelixir
Thank you so much! I will try to follow your step to see how to do without using
:functions。stefanluptak
This option was there in Elixir 1.12.3 for the last time (see Code — Elixir v1.12.3)
It was then deprecated in the version 1.13.0 (see elixir/CHANGELOG.md at v1.13 · elixir-lang/elixir · GitHub)
onelixir
Thank you so much! my searching ability is so weak…
The changelog just say:
I still don’t know what to do, if I cannot solve it, I have to just mark it and move on, until one day I can.
stefanluptak
First of all, I was dealing with a same/similar problem few weeks back, so your searching ability is not weak, I just already invested some time in it previously.
This
:functionsoption is just a list of functions that will be automatically imported thus available to be used in your view without the full module path needed. For example, if you would provide something likefunctions: [{MyApp.MyModule, [hello: 0]}], (0 being the arity (number of args) of the foo function) then you can use<%= foo() %>in your template. Without the:functionsoption, you just have to do<%= MyApp.MyModule.foo() %>, that is all.Hope this helps a bit.
onelixir
Thank you for your explanation again,
I understand you now, but I still don’t know what the alternative way to do if the official doesn’t suggest we pass
functionsoption? How to do that with env? I cannot just doEEx.eval_file("xxx.html.eex", [assigns: assigns], __ENV__).stefanluptak
Sorry, I have no knowledge of that and have no time to research it. Maybe someone else could help with that.
LostKobrakai
That expects there to be an alternative. Maybe there is none and you’re expected to instead update the templates to not depend on the deprecated functionality.