EEl - Embedded Erlang - template renderer (WIP)

Hi all!

I’m working on a library like the EEx for Elixir.
It compiles and evaluates a template, e.g:

1> eel:eval(<<"Hello, <%= Name .%>!">>, #{'Name' => <<"World">>}).
<<"Hello, World!">>

Or more complex like this:

It compiles the template to AST by erl_parse:parse_exprs and eval using erl_eval:exprs.

The lib repo:

I’m also working on a library on top of it. On any news, I will post about it here.


  • This library is a WIP, and ideas and help are very welcome :smiley:
  • The syntax highlighting of the screenshot comes from a fork of the vscode_erlang

On top of EEl, I’m creating WErl (I don’t have planned a good name for it, but this refers to “Web Erlang”). The idea is to use WebSocket to send changes to the page and only render what changed. EEl was designed thinking on this. Under the hood it uses morphdom in the front end, the same library used by Phoenix Framework, and on the server it uses cowboy as a dependency.
When the socket connects, it receives the static content as a list, then in any update sent by the server, it can resolve the dynamic content changes.

Some front code:

Partial server code:

WErl in action:

This lib it’s helping me to test the EEl and maybe can have some use cases in the future.
At the moment I’m working on a code abstraction.


Love this. You ended up using the name I was going to use when I mused about doing this, I suppose it’s a logical conclusion.

I think if this matured enough maybe it would be a great fit for OTP, at least I can think of lot of uses for it :slight_smile:


I just published an extension for VSCode that provides the syntax highlighting.


This is really great!

I’ve been concerned about how dependent Erlang community is on erlydtl, and the development of it has somewhat stagnated. Also, Erlang syntax in the template as opposed to Django templating language is much preferred.

Pardon my misunderstanding, but will it be possible to take the AST generated from the template and put it in an erlang module like the way erlydtl does it? Combined with the rebar3 erlydtl plugin this makes it easy to deploy releases.

Looking forward to the progress on this.

1 Like

Yes, this is in my roadmap for the eel. I think something like this is really helpful.


There is a new feature. Now you can compile the template to a module.



New feature available. There is a new module called eel_template. This module’s a gen_server and holds the last render information, by this, it has the capability to update only what changed.
For example:

1> {ok, Tpl} = eel:start_priv_file_template(eel, <<"greetings.html.eel">>).

2> eel_template:render(Tpl, #{'Who' => 'Erlang', 'Msg' => <<"Hello, EEl!">>}).
{<<"<p>Me: \"Hello, Erlang!\"</p>\n<p>You: \"Hello, EEl!\"</p>">>,
#{1 => <<"Erlang">>,2 => <<"Hello, EEl!">>}}

3> eel_template:render(Tpl).
{<<"<p>Me: \"Hello, Erlang!\"</p>\n<p>You: \"Hello, EEl!\"</p>">>,

4> eel_template:render(Tpl, #{'Msg' => <<"Hello again!">>}).
{<<"<p>Me: \"Hello, Erlang!\"</p>\n<p>You: \"Hello again!\"</p>">>,
#{2 => <<"Hello again!">>}}

The v(2) evaluates ‘Who’ and ‘Msg’ variables, v(3) none, and v(4) only the ‘Msg’.

1 Like