Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cvik/emo

Erlang Mustache rendering library
https://github.com/cvik/emo

Last synced: about 2 months ago
JSON representation

Erlang Mustache rendering library

Awesome Lists containing this project

README

        

## Emo - Erlang Mustache rendering library

Simple Mustache rendering app with mostly basic functionality implemented.
Doesnt yet support tripple curlies(or &-tags), partials or set delimiters.

Latest Tag: 0.3.0

## Exports

```erlang
-spec emo:render(Template::string(), Context::[{atom(), term()}]) -> iolist().
```

## Example usage

```erlang
1> l(emo).
ok
2> Context = [{type, "Fruits"},
{inventory, [[{name, "apple"}, {amount, "12"}],
[{name, "banana"}, {amount, "3"}, {pear, false}]]}].
[{type,"Fruits"},
{inventory,[[{name,"apple"},{amount,"12"}],
[{name,"banana"},{amount,"3"},{pear,false}]]}]
3> Template = "

{{type}}

    {{#inventory}}
  • {{name}} - {{amount}}
  • {{/inventory}}
{{not_shown}}{{^show_on_undef}}Default!{{/show_on_undef}}".
"

{{type}}

    {{#inventory}}
  • {{name}} - {{amount}}
  • {{/inventory}}
{{not_shown}}{{^show_on_undef}}Default!{{/show_on_undef}}"
4> iolist_to_binary(emo:render(Template, Context)).
<<"

Fruits


  • apple - 12

  • banana - 3

Default!">>
```

## License

Apache license version 2.0. See the LICENSE file for details.