You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although it spawns processes, I doubt that herml_manager may be a bottle neck.
I propose that a template be compiled to a module in-memory (the module name can be referred from the template path implicitly, or specified explicitly) with a function "render" so that it can render itself.
In other words, a template is converted into code instead of data. This way, the Erlang VM caches and manages the templates for us efficiently. When we want to render, just call it. When we want to update a template, just recompile it and the Erlang VM will automatically replace the old code with the new one for us.
For a feeling, ErlyDTL is working like this:
erlydtl:compile("/path/to/welcome.html", welcome_template),
welcome_template:render([
{name, "Johnny"},
{friends, [<<"Frankie Lee">>, <<"Judas Priest">>]},
{primes, [1, 2, "3", <<"5">>]}
]).
Although it spawns processes, I doubt that herml_manager may be a bottle neck.
I propose that a template be compiled to a module in-memory (the module name can be referred from the template path implicitly, or specified explicitly) with a function "render" so that it can render itself.
In other words, a template is converted into code instead of data. This way, the Erlang VM caches and manages the templates for us efficiently. When we want to render, just call it. When we want to update a template, just recompile it and the Erlang VM will automatically replace the old code with the new one for us.
For example, the library "erlang-gettext" can compile a plain text .po file to a module elegantly like this:
http://github.com/davide/erlang-gettext/blob/baee1560a705d1337fa05be822fde57abef1d312/src/gettext_generate.erl
For a feeling, ErlyDTL is working like this:
erlydtl:compile("/path/to/welcome.html", welcome_template),
welcome_template:render([
{name, "Johnny"},
{friends, [<<"Frankie Lee">>, <<"Judas Priest">>]},
{primes, [1, 2, "3", <<"5">>]}
]).
I'm new to AST. I found some instruction here:
http://www.evanmiller.org/write-a-template-compiler-for-erlang.html
The text was updated successfully, but these errors were encountered: