Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/cvik/emo
- Owner: cvik
- License: apache-2.0
- Created: 2014-07-02T13:48:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T05:27:08.000Z (over 7 years ago)
- Last Synced: 2024-10-17T23:45:09.219Z (3 months ago)
- Language: Erlang
- Size: 20.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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}}
"
{{type}}
- {{#inventory}}
- {{name}} - {{amount}} {{/inventory}}
4> iolist_to_binary(emo:render(Template, Context)).
<<"
Fruits
- apple - 12
- banana - 3
```
## License
Apache license version 2.0. See the LICENSE file for details.