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_file if I want to pass a functions option, what should I do?
Where does the functions option come from at the beginning? seems the document never wrote about this option, so how does the author of this book know this?
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 :functions as an option.
Thank you so much! my searching ability is so weak…
The changelog just say:
[Code] Environment options in Code.eval_quoted/3 and Code.eval_string/3, such as :aliases and :tracers, have been deprecated in favor of passing an environment
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.
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 :functions option 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 like functions: [{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 :functions option, you just have to do <%= MyApp.MyModule.foo() %>, that is all.
I understand you now, but I still don’t know what the alternative way to do if the official doesn’t suggest we pass functions option? How to do that with env? I cannot just do EEx.eval_file("xxx.html.eex", [assigns: assigns], __ENV__).
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.