Apply EEx bindings partially

47 views
Skip to first unread message

Attila Gulyas

unread,
Apr 2, 2017, 11:34:01 PM4/2/17
to elixir-lang-core
Hi,

Would there be a need for something like this? Or is there already something like this?

An example:

s = "<%=   a %>, <%= b %> and another <%= c %>"
EEx.partial_eval_string(s)
#> "<%=   a %>, <%= b %> and another <%= c %>"
EEx.partial_eval_string s,[b: "pie", c: "one"]
#> "<%=   a %>, pie and another one"

The basic implementation:

It would be pretty easy to apply it to the `eval_*`s and `function_from_*`s but it is just as easy to write a wrapper around them in a current project.

Thank you!
Attila

OvermindDL1

unread,
Apr 3, 2017, 12:16:54 PM4/3/17
to elixir-lang-core
Is there a gain to it beyond just accumulating the arguments then calling 'render' once they are all accumulated?

José Valim

unread,
Apr 3, 2017, 9:26:11 PM4/3/17
to elixir-l...@googlegroups.com
If I understand the current implementation correctly, it also only applies to binding like <%= a %>, if it becomes <%= a + b %>, then the partial expansion does not work as expected.


José Valim
Skype: jv.ptec
Founder and Director of R&D

Gulyás Attila

unread,
Apr 4, 2017, 12:55:17 AM4/4/17
to elixir-l...@googlegroups.com
OvermindDL1 and José, thanks for your comments! It seems that (a) I  started overcomplicating things  and (b) didn't really think it through.

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/pYSfP3x7vwc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2d7655f0-6ccc-4337-a1f5-3a67583bff2b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
 
Reply all
Reply to author
Forward
0 new messages