Mustache template engine for Erlang/OTP.
A logic-less templates.
- Binary and map base.
- Do not use a regular expression !!
- Support an associative array for the before R17.
Add the following settings.
%% rebar.config
%% If you want to use a map is necessary
{erl_opts, [
{platform_define, "^[0-9]+", namespaced_types}
]}.
{deps,
[
{mustache, ".*", {git, "git://github.com/soranoba/mustache.git", {branch, "master"}}}
]}.- Mastache Manual
- Support all of syntax !
Map (R17 or later)
1> mustache:render(<<"{{name}}">>, #{"name" => "hoge"}).
<<"hoge">>
2> Template1 = mustache:parse_binary(<<"{{name}}">>).
...
3> mustache:compile(Template1, #{"name" => "hoge"}).
<<"hoge">>
4> Template2 = mustache:parse_file(<<"./hoge.mustache">>).
...
5> mustache:compile(Template2, #{"name" => "hoge"}).
<<"hoge">>Associative array
1> mustache:render(<<"{{name}}">>, [{"name", "hoge"}]).
<<"hoge">>
2> Template1 = mustache:parse_binary(<<"{{name}}">>).
...
3> mustache:compile(Template1, [{"name", "hoge"}]).
<<"hoge">>
4> Template2 = mustache:parse_file(<<"./hoge.mustache">>).
...
5> mustache:compile(Template2, [{"name", "hoge"}]).
<<"hoge">>You want more information, see the doc.
- The number of new line.
- New line in the template has left all.
- Lambda expression is included wasted processing.
- Because it is optimized to
parse_string/1+compile/2.
| moyombo/mustache.erl | soranoba/mustache | |
|---|---|---|
| score (time) | 1016414 | 33001 |
In this case, it is 30 times faster than moyombo/mustache.erl
Pull request is welcome =D