54) ElixirConf US 2018 – Closing Keynote – Chris McCord

Yes, you can try that. If I were to follow that path (I’ve actually tried to do it for about 30mins or something, and it’s not trivial), I’d do the following:

  1. Don’t try to produce a valid expression at all steps. You probably need to keep some context of what variables you have already bound and stuff like that

  2. Instead of “folding over a quoted expression” (which is what an engine currently does), fold over a more complex struct (e.g. %Context{}), which keeps the metadata you need. You do have some experience in writing compilers, so you probably know what you need (NimbleParsec, in particular, is a work of art, although I can’t understand much of the source)

  3. You’ll probably need some minimal postprocessing anyway.

I can help, but I can’t commit to deadlines: I might have something ready in 1 day or in 1 month. And in any case, I’d like to go the way of rewriting the already compiled template according to a “typical” engine (nothing special, just personal preference).

If you want to try to build the template as you parse the EEx template, I suggest you go that way while I try to transform the already compiled template. In any case, the optimum approach will probably take a bit from both perspectives.

I have a sandbox project named PhoenixUndeadView where I try some approaches. I’ll publish it today or tomorrow so you can see for yourself what I’m doing (not much, currently). I’ve started a topic to sorta blog about it, but most (here), but most of the interesting discussion is in this topic :slight_smile:

5 Likes