Skip to content
 
 

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mustache

Mustache template engine for Erlang/OTP.

What is Mustach ?

A logic-less templates.

Overview

  • Binary and map base.
  • Do not use a regular expression !!
  • Support an associative array for the before R17.

Usage

Use as a library

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"}}}
  ]}.

How to use simple Mustache

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">>

More information

You want more information, see the doc.

Attention

  • 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.

Simple Benchmark

moyombo/mustache.erl soranoba/mustache
score (time) 1016414 33001

In this case, it is 30 times faster than moyombo/mustache.erl

Contribute

Pull request is welcome =D

License

MIT License

About

Mustache template engine for Erlang/OTP.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages