phoenix_mjml
phoenix_mjml copied to clipboard
switch eex and mjml rendering
Please correct me if I am wrong but in your implementation, you generate html then compile it with EEx. This way you aren't able to generate really dynamic mails because mjml can't decide the exact number of elements in the page. Eex compilation should happen before to generate proper responsives emails.
hi @julien-leclercq, the flow is like this: eex -> mjml -> html
Just checked your implement, quite confuse 🤔
How could it be so ?
your Module entry point is compile
which is
def compile(path, _name) do
path
|> generate_html_path
|> compile_content
end
you call EEx
in compile_content and mjml
in generate_html_path
we are confusing each other right now
My benchmarks with both implementation https://gist.github.com/julien-leclercq/5fbe854f7c87f072b7bb799b283acbb7
ops, my bad. the flow will be mjml -> html -> eex 😂 . It seems like your solution is faster, it doesn't need to create a new file 🤔
clearly the benches show no difference because the bottleneck is in the mjml bootup. But we need to change the flow to EEx -> mjml -> html to allow mjml to generate truly responsive email
you are right, let's stick with your solution 👍🏻
I am working on inversing the flow but if you have an idea I would be glad to cooperate on this !
What package do you use to render your emails ? I personally use Bamboo, I think would be smarter to implement a Bamboo engine than a Phoenix Engine, what do you think ?
I use Bamboo, can you explain why Bamboo engine is better than Phoenix Engine 🤔
Because Phoenix Engine expect its unique function compile
to return a quoted expression to be then evaluated. In your process that's what EEx does.
What we need here is EEx
to run before mjml
to ensure the output to be a responsive html email. I would go with a Bamboo phoenix engine extension that call mjml
at the end of the render function. What do you think of it ?
I am not a native english speaker so if it is unclear please don't be afraid to ask further explanations.
created a repo for it be free to fork and pull request (I don't think I am gonna push today I have other things to do) https://github.com/derniercri/bamboo_mjml