pax_global_header 0000666 0000000 0000000 00000000064 14143115056 0014512 g ustar 00root root 0000000 0000000 52 comment=529a6658e7b4963c208d6c97de88bd5936c2e3b2
erlang-bbmustache-1.12.2/ 0000775 0000000 0000000 00000000000 14143115056 0015160 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/.circleci/ 0000775 0000000 0000000 00000000000 14143115056 0017013 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/.circleci/config.yml 0000664 0000000 0000000 00000002063 14143115056 0021004 0 ustar 00root root 0000000 0000000 version: 2.1
jobs:
test:
parameters:
version:
type: string
commands:
type: string
docker:
- image: circleci/erlang:<< parameters.version >>
auth:
username: $DOCKERHUB_USER
password: $DOCKERHUB_PASSWORD
steps:
- checkout
- run: rm -rf _build; make << parameters.commands >>
workflows:
version: 2
general:
jobs:
- test:
name: "test-24"
version: "24"
commands: "ci edoc"
- test:
name: "test-23.3"
version: "23.3"
commands: "ci edoc"
- test:
name: "test-22.3"
version: "22.3"
commands: "ci edoc"
- test:
name: "test-21.3"
version: "21.3"
commands: "ci edoc"
- test:
name: "test-20.3"
version: "20.3"
commands: "ci"
- test:
name: "test-19.3"
version: "19.3"
commands: "ci"
- test:
name: "test-18.3"
version: "18.3"
commands: "ci"
erlang-bbmustache-1.12.2/.github/ 0000775 0000000 0000000 00000000000 14143115056 0016520 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/.github/FUNDING.yml 0000664 0000000 0000000 00000001361 14143115056 0020336 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [soranoba] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://paypal.me/soranoba"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
erlang-bbmustache-1.12.2/.gitignore 0000664 0000000 0000000 00000000315 14143115056 0017147 0 ustar 00root root 0000000 0000000 .eunit
deps
*.o
*.beam
*.plt
erl_crash.dump
ebin
rel/example_project
.concrete/DEV_MODE
.rebar
*.swp
tags
*~
doc/*
!doc/overview.edoc
!doc/*.md
.rebar
_build
.rebar3
_checkouts
benchmarks/.tmp
/bbmustache
erlang-bbmustache-1.12.2/LICENSE 0000664 0000000 0000000 00000002075 14143115056 0016171 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2015 Hinagiku Soranoba
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
erlang-bbmustache-1.12.2/Makefile 0000664 0000000 0000000 00000001200 14143115056 0016611 0 ustar 00root root 0000000 0000000 CWD=$(shell pwd)
.PHONY: ct
all: compile escriptize eunit ct xref dialyze edoc
ci: compile escriptize eunit ct xref dialyze
compile:
@./rebar3 as dev compile
xref:
@./rebar3 as dev xref
clean:
@./rebar3 clean
ct: escriptize
@CMD_TOOL=$(CWD)/bbmustache ./rebar3 ct
cover:
@./rebar3 cover
eunit:
@./rebar3 eunit
edoc:
@./rebar3 as doc edoc
start:
@./rebar3 as dev shell
dialyze:
@./rebar3 as dev dialyzer
bench:
@./rebar3 as test compile
@./rebar3 as bench compile
@./benchmarks/bench.escript
escriptize:
@./rebar3 as dev escriptize
@cp _build/dev/bin/bbmustache .
install: escriptize
cp bbmustache /usr/local/bin
erlang-bbmustache-1.12.2/README.md 0000664 0000000 0000000 00000012273 14143115056 0016444 0 ustar 00root root 0000000 0000000 bbmustache
===========
[](https://circleci.com/gh/soranoba/bbmustache/tree/master)
[](https://hex.pm/packages/bbmustache)
Binary pattern match Based Mustache template engine for Erlang/OTP.
## Overview
- Binary pattern match based mustache template engine for Erlang/OTP.
- It means do not use regular expressions.
- Support maps and associative arrays.
- Officially support is OTP17 or later.
### What is Mustache ?
A logic-less templates.
- [{{mustache}}](http://mustache.github.io/)
## Usage
### Quick start
```bash
$ git clone git://github.com/soranoba/bbmustache.git
$ cd bbmustache
$ make start
Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:true]
Eshell V6.3 (abort with ^G)
1> bbmustache:render(<<"{{name}}">>, #{"name" => "hoge"}).
<<"hoge">>
2> bbmustache:render(<<"{{name}}">>, [{"name", "hoge"}]).
<<"hoge">>
```
### Use as a library
Add the following settings.
```erlang
%% rebar (rebar.config)
{deps,
[
{bbmustache, ".*", {git, "git://github.com/soranoba/bbmustache.git", {branch, "master"}}}
]}.
%% rebar3 (rebar.config)
{deps, [bbmustache]}.
```
### How to use simple Mustache
Map
```erlang
1> bbmustache:render(<<"{{name}}">>, #{"name" => "hoge"}).
<<"hoge">>
2> Template1 = bbmustache:parse_binary(<<"{{name}}">>).
...
3> bbmustache:compile(Template1, #{"name" => "hoge"}).
<<"hoge">>
4> Template2 = bbmustache:parse_file(<<"./hoge.mustache">>).
...
5> bbmustache:compile(Template2, #{"name" => "hoge"}).
<<"hoge">>
```
Associative array
```erlang
1> bbmustache:render(<<"{{name}}">>, [{"name", "hoge"}]).
<<"hoge">>
2> Template1 = bbmustache:parse_binary(<<"{{name}}">>).
...
3> bbmustache:compile(Template1, [{"name", "hoge"}]).
<<"hoge">>
4> Template2 = bbmustache:parse_file(<<"./hoge.mustache">>).
...
5> bbmustache:compile(Template2, [{"name", "hoge"}]).
<<"hoge">>
```
### Use as a command-line tool
```bash
make escriptize
echo '{"name", "hoge"}.' > vars.config
echo '{{name}}' > template.mustache
./bbmustache -d vars.config template.mustache
hoge
```
Data files (-d) support a single assoc list, a single map, and [consult](https://erlang.org/doc/man/file.html#consult-1) format.
Note: the behind term has a high priority in all cases. it is a result of supporting to allow for embedding relative file paths as in [config](http://erlang.org/doc/man/config.html).
### More information
- For the alias of mustache, Please refer to [ManPage](http://mustache.github.io/mustache.5.html) and [Specification](https://github.com/mustache/spec)
- For the options of this library, please see [doc](doc)
- For the functions supported by this library, please see [here](benchmarks/README.md)
## FAQ
### Avoid http escaping
```erlang
%% Please use `{{{tag}}}`
1> bbmustache:render(<<"
{{{title}}}
">>, #{"title" => "I like Erlang & mustache"}).
<<"I like Erlang & mustache
">>
%% If you should not want to use `{{{tag}}}`, escape_fun can be use.
1> bbmustache:render(<<"{{title}}
">>, #{"title" => "I like Erlang & mustache"}, [{escape_fun, fun(X) -> X end}]).
<<"I like Erlang & mustache
">>
```
### Already used `{` and `}` for other uses (like escript)
```erlang
1> io:format(bbmustache:render(<<"
1> {{=<< >>=}}
1> {deps, [
1> <<#deps>>
1> {<>, \"<>\"}<<^last?>>,<>
1> <>
1> ]}.
1> ">>, #{"deps" => [
1> #{"name" => "bbmustache", "version" => "1.6.0"},
1> #{"name" => "jsone", "version" => "1.4.6", "last?" => true}
1> ]})).
{deps, [
{bbmustache, "1.6.0"},
{jsone, "1.4.6"}
]}.
ok
```
### Want to use something other than string for key
```erlang
1> bbmustache:render(<<"{{{title}}}
">>, #{title => "I like Erlang & mustache"}, [{key_type, atom}]).
<<"I like Erlang & mustache
">>
2> bbmustache:render(<<"{{{title}}}
">>, #{<<"title">> => "I like Erlang & mustache"}, [{key_type, binary}]).
<<"I like Erlang & mustache
">>
```
### Want to provide a custom serializer for Erlang Terms
```erlang
1> bbmustache:render(<<"{{title}}
">>, #{title => "I like Erlang & mustache"}, [{key_type, atom}, {value_serializer, fun(X) -> X end}]).
<<"I like Erlang & mustache
">>
2> bbmustache:render(<<"{{{title}}}
">>, #{<<"title">> => "I like Erlang & mustache"}, [{key_type, binary}, {value_serializer, fun(X) -> <<"replaced">> end}]).
<<"replaced
">>
3> bbmustache:render(<<"{{{title}}}
">>, #{<<"title">> => #{<<"nested">> => <<"value">>}}, [{key_type, binary}, {value_serializer, fun(X) -> jsone:encode(X) end}]).
<<"{\"nested\": \"value\"}
">>
4> bbmustache:render(<<"{{title}}
">>, #{<<"title">> => #{<<"nested">> => <<"value">>}}, [{key_type, binary}, {value_serializer, fun(X) -> jsone:encode(X) end}]).
<<"{"nested":"value"}
">>
```
## Attention
- Lambda expression is included wasted processing.
- Because it is optimized to `parse_binary/1` + `compile/2`.
## Comparison with other libraries
[Benchmarks and check the reference implementation](benchmarks/README.md)
## Contribute
Pull request is welcome =D
## License
[MIT License](LICENSE)
erlang-bbmustache-1.12.2/benchmarks/ 0000775 0000000 0000000 00000000000 14143115056 0017275 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/benchmarks/.tmp/ 0000775 0000000 0000000 00000000000 14143115056 0020153 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/benchmarks/.tmp/.gitkeep 0000664 0000000 0000000 00000000000 14143115056 0021572 0 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/benchmarks/README.md 0000664 0000000 0000000 00000020750 14143115056 0020560 0 ustar 00root root 0000000 0000000 # Benchmarks
[benchmark script](bench.escript)
|Library|Time |
|:------|:-----|
|bbmustache | 39122 |
|mustache.erl | 673416 |
# Check the reference implementation
:warning: For libraries other than bbmustache, there is a possibility that there is a miss.
## comments
https://github.com/mustache/spec/tree/v1.2.1/specs/comments.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Inline|:white_check_mark:|:white_check_mark:|
|Multiline|:white_check_mark:|:white_check_mark:|
|Standalone|:white_check_mark:||
|Indented Standalone|:white_check_mark:||
|Standalone Line Endings|:white_check_mark:||
|Standalone Without Previous Line|:white_check_mark:||
|Standalone Without Newline|:white_check_mark:||
|Multiline Standalone|:white_check_mark:||
|Indented Multiline Standalone|:white_check_mark:||
|Indented Inline|:white_check_mark:|:white_check_mark:|
|Surrounding Whitespace|:white_check_mark:|:white_check_mark:|
## delimiters
https://github.com/mustache/spec/tree/v1.2.1/specs/delimiters.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Pair Behavior|:white_check_mark:||
|Special Characters|:white_check_mark:||
|Sections|:white_check_mark:||
|Inverted Sections|:white_check_mark:||
|Partial Inheritence|:white_check_mark:||
|Post-Partial Behavior|:white_check_mark:||
|Surrounding Whitespace|:white_check_mark:||
|Outlying Whitespace (Inline)|:white_check_mark:||
|Standalone Tag|:white_check_mark:||
|Indented Standalone Tag|:white_check_mark:||
|Standalone Line Endings|:white_check_mark:||
|Standalone Without Previous Line|:white_check_mark:||
|Standalone Without Newline|:white_check_mark:||
|Pair with Padding|:white_check_mark:||
## interpolation
https://github.com/mustache/spec/tree/v1.2.1/specs/interpolation.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|No Interpolation|:white_check_mark:|:white_check_mark:|
|Basic Interpolation|:white_check_mark:|:white_check_mark:|
|HTML Escaping|:white_check_mark:||
|Triple Mustache|:white_check_mark:|:white_check_mark:|
|Ampersand|:white_check_mark:|:white_check_mark:|
|Basic Integer Interpolation|:white_check_mark:|:white_check_mark:|
|Triple Mustache Integer Interpolation|:white_check_mark:|:white_check_mark:|
|Ampersand Integer Interpolation|:white_check_mark:|:white_check_mark:|
|Basic Decimal Interpolation|:white_check_mark:|:white_check_mark:|
|Triple Mustache Decimal Interpolation|:white_check_mark:|:white_check_mark:|
|Ampersand Decimal Interpolation|:white_check_mark:|:white_check_mark:|
|Basic Null Interpolation|:white_check_mark:||
|Triple Mustache Null Interpolation|:white_check_mark:||
|Ampersand Null Interpolation|:white_check_mark:||
|Basic Context Miss Interpolation|:white_check_mark:|:white_check_mark:|
|Triple Mustache Context Miss Interpolation|:white_check_mark:|:white_check_mark:|
|Ampersand Context Miss Interpolation|:white_check_mark:|:white_check_mark:|
|Dotted Names - Basic Interpolation|:white_check_mark:||
|Dotted Names - Triple Mustache Interpolation|:white_check_mark:||
|Dotted Names - Ampersand Interpolation|:white_check_mark:||
|Dotted Names - Arbitrary Depth|:white_check_mark:||
|Dotted Names - Broken Chains|:white_check_mark:||
|Dotted Names - Broken Chain Resolution|:white_check_mark:||
|Dotted Names - Initial Resolution|:white_check_mark:||
|Dotted Names - Context Precedence|:white_check_mark:||
|Implicit Iterators - Basic Interpolation|:white_check_mark:||
|Implicit Iterators - HTML Escaping|:white_check_mark:||
|Implicit Iterators - Triple Mustache|:white_check_mark:||
|Implicit Iterators - Ampersand|:white_check_mark:||
|Implicit Iterators - Basic Integer Interpolation|:white_check_mark:||
|Interpolation - Surrounding Whitespace|:white_check_mark:|:white_check_mark:|
|Triple Mustache - Surrounding Whitespace|:white_check_mark:|:white_check_mark:|
|Ampersand - Surrounding Whitespace|:white_check_mark:|:white_check_mark:|
|Interpolation - Standalone|:white_check_mark:|:white_check_mark:|
|Triple Mustache - Standalone|:white_check_mark:|:white_check_mark:|
|Ampersand - Standalone|:white_check_mark:|:white_check_mark:|
|Interpolation With Padding|:white_check_mark:|:white_check_mark:|
|Triple Mustache With Padding|:white_check_mark:|:white_check_mark:|
|Ampersand With Padding|:white_check_mark:|:white_check_mark:|
## inverted
https://github.com/mustache/spec/tree/v1.2.1/specs/inverted.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Falsey|:white_check_mark:|:white_check_mark:|
|Truthy|:white_check_mark:|:white_check_mark:|
|Null is falsey|:white_check_mark:||
|Context|:white_check_mark:|:white_check_mark:|
|List|:white_check_mark:|:white_check_mark:|
|Empty List|:white_check_mark:|:white_check_mark:|
|Doubled|:white_check_mark:|:white_check_mark:|
|Nested (Falsey)|:white_check_mark:||
|Nested (Truthy)|:white_check_mark:||
|Context Misses|:white_check_mark:|:white_check_mark:|
|Dotted Names - Truthy|:white_check_mark:||
|Dotted Names - Falsey|:white_check_mark:||
|Dotted Names - Broken Chains|:white_check_mark:||
|Surrounding Whitespace|:white_check_mark:||
|Internal Whitespace|:white_check_mark:||
|Indented Inline Sections|:white_check_mark:||
|Standalone Lines|:white_check_mark:|:white_check_mark:|
|Standalone Indented Lines|:white_check_mark:||
|Standalone Line Endings|:white_check_mark:||
|Standalone Without Previous Line|:white_check_mark:||
|Standalone Without Newline|:white_check_mark:||
|Padding|:white_check_mark:|:white_check_mark:|
## partials
https://github.com/mustache/spec/tree/v1.2.1/specs/partials.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Basic Behavior|:white_check_mark:||
|Failed Lookup|:white_check_mark:||
|Context|:white_check_mark:||
|Recursion|:white_check_mark:||
|Surrounding Whitespace|:white_check_mark:||
|Inline Indentation|:white_check_mark:||
|Standalone Line Endings|:white_check_mark:||
|Standalone Without Previous Line|:white_check_mark:||
|Standalone Without Newline|:white_check_mark:||
|Standalone Indentation|:white_check_mark:||
|Padding Whitespace|:white_check_mark:||
## sections
https://github.com/mustache/spec/tree/v1.2.1/specs/sections.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Truthy|:white_check_mark:|:white_check_mark:|
|Falsey|:white_check_mark:|:white_check_mark:|
|Null is falsey|:white_check_mark:||
|Context|:white_check_mark:||
|Parent contexts|:white_check_mark:||
|Variable test|:white_check_mark:||
|List Contexts|:white_check_mark:||
|Deeply Nested Contexts|:white_check_mark:||
|List|:white_check_mark:||
|Empty List|:white_check_mark:|:white_check_mark:|
|Doubled|:white_check_mark:|:white_check_mark:|
|Nested (Truthy)|:white_check_mark:||
|Nested (Falsey)|:white_check_mark:||
|Context Misses|:white_check_mark:|:white_check_mark:|
|Implicit Iterator - String|:white_check_mark:||
|Implicit Iterator - Integer|:white_check_mark:||
|Implicit Iterator - Decimal|:white_check_mark:||
|Implicit Iterator - Array|:white_check_mark:||
|Dotted Names - Truthy|:white_check_mark:||
|Dotted Names - Falsey|:white_check_mark:||
|Dotted Names - Broken Chains|:white_check_mark:||
|Surrounding Whitespace|:white_check_mark:||
|Internal Whitespace|:white_check_mark:||
|Indented Inline Sections|:white_check_mark:||
|Standalone Lines|:white_check_mark:|:white_check_mark:|
|Indented Standalone Lines|:white_check_mark:||
|Standalone Line Endings|:white_check_mark:||
|Standalone Without Previous Line|:white_check_mark:||
|Standalone Without Newline|:white_check_mark:||
|Padding|:white_check_mark:|:white_check_mark:|
## ~inheritance
https://github.com/mustache/spec/tree/v1.2.1/specs/~inheritance.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Default|||
|Variable|||
|Triple Mustache|||
|Sections|||
|Negative Sections|||
|Mustache Injection|||
|Inherit|||
|Overridden content|||
|Data does not override block|||
|Data does not override block default|||
|Overridden parent|||
|Two overridden parents|||
|Override parent with newlines|||
|Inherit indentation|||
|Only one override|||
|Parent template|||
|Recursion|||
|Multi-level inheritance|||
|Multi-level inheritance, no sub child|||
|Text inside parent|||
|Text inside parent|||
## ~lambdas
https://github.com/mustache/spec/tree/v1.2.1/specs/~lambdas.yml
| |bbmustache|mustache.erl|
|:---|:------------|:------------|
|Interpolation|||
|Interpolation - Expansion|||
|Interpolation - Alternate Delimiters|||
|Interpolation - Multiple Calls|||
|Escaping|||
|Section|||
|Section - Expansion|||
|Section - Alternate Delimiters|||
|Section - Multiple Calls|||
|Inverted Section|:white_check_mark:|:white_check_mark:|
erlang-bbmustache-1.12.2/benchmarks/bench.escript 0000775 0000000 0000000 00000013656 14143115056 0021765 0 ustar 00root root 0000000 0000000 #!/usr/bin/env escript
%% -*- erlang -*-
-define(TEST_LIBRARIES,
[
{"bbmustache",
fun (Template, Data) ->
bbmustache:render(Template, Data, [{key_type, binary}])
end},
{"mustache.erl",
fun (Template, Data) ->
KeyConvFun = fun(B) -> binary_to_atom(B, latin1) end,
ValueConvFun = fun(V) when is_binary(V) -> binary_to_list(V);
(O) -> O
end,
list_to_binary(mustache:render(binary_to_list(Template),
dict:from_list(conv_recursive(Data, KeyConvFun, ValueConvFun))))
end}
]).
main(_) ->
ok = code:add_pathsz(filelib:wildcard(filename:absname("_build/**/ebin"))),
ok = file:set_cwd("benchmarks/.tmp"),
Jsons = filelib:wildcard("../../_build/test/lib/mustache_spec/specs/*.json"),
io:format("test files:~n"),
[io:format(" ~s~n", [Json]) || Json <- Jsons],
Result0 = main1(Jsons, []),
Result = Result0 ++ [{<<"benches">>, bench_main()}],
ok = file:write_file("../README.md",
bbmustache:compile(bbmustache:parse_file("../output.mustache"), Result, [{key_type, binary}])).
bench_main() ->
Template = "Hello {{name}} You have just won {{value}} dollars! {{#in_ca}} Well, {{taxed_value}} dollars, after taxes. {{/in_ca}}",
MapData = #{<<"name">> => "Chris", <<"value">> => 10000, <<"taxed_value">> => 10000 - (10000 * 0.4), <<"in_ca">> => true},
DictData = dict:from_list([{name, "Chris"}, {value, 10000}, {taxed_value, 10000 - (10000 * 0.4)}, {in_ca, true}]),
Benches = [
{"bbmustache", fun(T, D) -> bbmustache:render(T, D, [{key_type, binary}]) end,
list_to_binary(Template), MapData},
{"mustache.erl", fun(T, D) -> mustache:render(T, D) end,
Template, DictData}
],
[
[{<<"library">>, Library},
{<<"result">>, bench_run(Render, T, D)}] || {Library, Render, T, D} <- Benches
].
bench_run(Render, Template, Data) ->
lists:sum([begin {T, _} = timer:tc(Render, [Template, Data]), T end || _ <- lists:seq(1, 1000)]).
main1([], Result) ->
[{<<"spec_files">>, lists:reverse(Result)}];
main1([JsonPath | Rest], Result) ->
{ok, JsonBin} = file:read_file(JsonPath),
JsonDec = jsone:decode(JsonBin, [{object_format, proplist}]),
Tests = proplists:get_value(<<"tests">>, JsonDec),
Ret = main2(Tests, []),
main1(Rest, [[{<<"spec">>, filename:basename(JsonPath, ".json")},
{<<"libraries">>, [[{<<"library">>, L}] || {L, _} <- ?TEST_LIBRARIES]},
{<<"tests">>, Ret}
] | Result]).
main2([], Result) ->
lists:reverse(Result);
main2([Test | Tests], Result) ->
Ret = [spec_test(Render, Test) || {_, Render} <- ?TEST_LIBRARIES],
main2(Tests, [[
{<<"test">>, proplists:get_value(<<"name">>, Test)},
{<<"results">>, Ret}
] | Result]).
spec_test(Render, Assoc) ->
Data0 = proplists:get_value(<<"data">>, Assoc),
Data = case is_list(Data0) of
false -> Data0;
true ->
case proplists:get_value(<<"lambda">>, Data0) of
undefined -> Data0;
Lambda -> [{<<"lambda">>, lambda(Lambda)} | proplists:delete(<<"lambda">>, Data0)]
end
end,
Expected = proplists:get_value(<<"expected">>, Assoc),
Template = proplists:get_value(<<"template">>, Assoc),
Partials = proplists:get_value(<<"partials">>, Assoc, []),
ok = clean_dir("."),
ok = lists:foreach(fun(P) -> write_file(P) end, Partials),
{Pid, Ref} = spawn_monitor(fun() -> Expected = Render(Template, Data) end),
Result = receive
{'DOWN', Ref, _, _, Reason} -> Reason =:= normal
after 3000 ->
exit(Pid, kill),
demonitor(Ref, [flush]),
false
end,
[{<<"result">>, Result}].
clean_dir(Dir) ->
lists:foreach(fun(F) -> file:delete(F) end,
filelib:wildcard(filename:join(Dir, "*.mustache"))).
write_file({PartialFilename, PartialData}) ->
ok = file:write_file(<>, PartialData);
write_file(_) ->
ok.
conv_recursive([{} | Rest], KeyConvFun, ValueConvFun) ->
conv_recursive(Rest, KeyConvFun, ValueConvFun);
conv_recursive([{_, _} | _] = AssocList, KeyConvFun, ValueConvFun) ->
lists:foldl(fun({Key, [{_, _} | _] = Value}, Acc) ->
[{KeyConvFun(Key), conv_recursive(Value, KeyConvFun, ValueConvFun)} | Acc];
({Key, Value}, Acc) when is_list(Value) ->
[{KeyConvFun(Key), [conv_recursive(X, KeyConvFun, ValueConvFun) || X <- Value]} | Acc];
({Key, Value}, Acc) ->
[{KeyConvFun(Key), ValueConvFun(Value)} | Acc]
end, [], AssocList);
conv_recursive(Other, _, _) ->
Other.
list_to_dict_recursive([{_, _} | _] = AssocList) ->
lists:foldl(fun({Key, [{_, _} | _] = Value}, Dict) ->
dict:store(Key, list_to_dict_recursive(Value), Dict);
({Key, Value}, Dict) when is_list(Value) ->
dict:store(Key, [list_to_dict_recursive(X) || X <- Value], Dict);
({Key, Value}, Dict) ->
dict:store(Key, Value, Dict)
end, dict:new(), AssocList);
list_to_dict_recursive(Other) ->
Other.
lambda(LambdaList) ->
LambdaStr = binary_to_list(proplists:get_value(<<"erlang">>, LambdaList)),
io:format("~s~n", [LambdaStr]),
{ok, Token, _} = erl_scan:string(LambdaStr),
{ok, [Form]} = erl_parse:parse_exprs(Token),
{value, Fun, _} = erl_eval:expr(Form, erl_eval:new_bindings()),
Fun.
erlang-bbmustache-1.12.2/benchmarks/output.mustache 0000664 0000000 0000000 00000001144 14143115056 0022370 0 ustar 00root root 0000000 0000000 # Benchmarks
[benchmark script](bench.escript)
|Library|Time |
|:------|:-----|
{{# benches }}
|{{ library }} | {{ result }} |
{{/ benches }}
# Check the reference implementation
:warning: For libraries other than bbmustache, there is a possibility that there is a miss.
{{# spec_files }}
## {{ spec }}
https://github.com/mustache/spec/tree/v1.2.1/specs/{{ spec }}.yml
| |{{# libraries }}{{ library }}|{{/ libraries }}
|:---|{{# libraries }}:------------|{{/ libraries }}
{{# tests }}
|{{ test }}|{{# results }}{{# result }}:white_check_mark:{{/ result }}|{{/ results }}
{{/ tests }}
{{/ spec_files }}
erlang-bbmustache-1.12.2/ct/ 0000775 0000000 0000000 00000000000 14143115056 0015566 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/ct/bbmustache_SUITE.erl 0000664 0000000 0000000 00000033743 14143115056 0021372 0 ustar 00root root 0000000 0000000 %% @copyright 2015 Hinagiku Soranoba All Rights Reserved.
-module(bbmustache_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-export([
all/0, groups/0,
init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2,
variables_ct/1, sections_ct1/1, sections_ct2/1, sections_ct3/1, sections_ct4/1,
lambdas_ct/1, comments_ct/1, partials_ct/1, delimiter_ct/1, dot_ct/1, dot_unescape_ct/1,
indent_partials_ct/1, not_found_partials_ct1/1, not_found_partials_ct2/1, not_found_partials_ct3/1,
context_stack_ct/1, context_stack_ct2/1, partial_custom_reader_ct/1,
unicode_render_ct/1
]).
-define(ALL_TEST, [variables_ct, sections_ct1, sections_ct2, sections_ct3, sections_ct4,
lambdas_ct, comments_ct, partials_ct, delimiter_ct, dot_ct, dot_unescape_ct,
indent_partials_ct, not_found_partials_ct1, not_found_partials_ct2, not_found_partials_ct3,
context_stack_ct, context_stack_ct2, partial_custom_reader_ct, unicode_render_ct]).
-define(config2, proplists:get_value).
-define(debug(X), begin io:format("~p", [X]), X end).
%%----------------------------------------------------------------------------------------------------------------------
%% 'common_test' Callback API
%%----------------------------------------------------------------------------------------------------------------------
all() ->
[
{group, assoc_list},
{group, maps},
{group, assoc_list_into_maps},
{group, maps_into_assoc_list},
{group, atom_key},
{group, binary_key}
].
groups() ->
[
{assoc_list, [], ?ALL_TEST},
{maps, [], ?ALL_TEST},
{assoc_list_into_maps, [], ?ALL_TEST},
{maps_into_assoc_list, [], ?ALL_TEST},
{atom_key, [], ?ALL_TEST},
{binary_key, [], ?ALL_TEST}
].
init_per_suite(Config) ->
Config.
end_per_suite(_) ->
ok.
init_per_group(assoc_list, Config) ->
[{data_conv, fun(X) -> X end} | Config];
init_per_group(maps, Config) ->
[{data_conv, fun list_to_maps_recursive/1} | Config];
init_per_group(assoc_list_into_maps, Config) ->
[{data_conv, fun maps:from_list/1} | Config];
init_per_group(maps_into_assoc_list, Config) ->
[{data_conv, fun(X) -> deps_list_to_maps(X, 2) end} | Config];
init_per_group(atom_key, Config) ->
[{data_conv, fun(X) -> key_conv_recursive(X, fun erlang:list_to_atom/1) end},
{options, [{key_type, atom}]}
| Config];
init_per_group(binary_key, Config) ->
[{data_conv, fun(X) -> key_conv_recursive(X, fun erlang:list_to_binary/1) end},
{options, [{key_type, binary}]}
| Config].
end_per_group(_, _) ->
ok.
%%----------------------------------------------------------------------------------------------------------------------
%% Common Test Functions
%%----------------------------------------------------------------------------------------------------------------------
variables_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"variables.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"variables.result">>])),
Data = [{"name", "Chris"}, {"company", "GitHub"}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
sections_ct1(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"false_values.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"false_values.result">>])),
Data1 = [{"person", false}],
Data2 = [{"person", []}],
Data3 = [],
[?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(X)), ?config2(options, Config, [])))
|| X <- [Data1, Data2, Data3]].
sections_ct2(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"non-empty.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"non-empty.result">>])),
Data = [{"repo", [ [{"name", "resque"}], [{"name", "hub"}], [{"name", "rip"}]]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
sections_ct3(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"non-false.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"non-false.result">>])),
Data = [{"person?", [{"name", "Jon"}]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
sections_ct4(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"invarted.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"invarted.result">>])),
Data = [{"repo", []}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
lambdas_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"lambdas.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"lambdas.result">>])),
F = fun(Text, Render) -> ["", Render(Text), ""] end,
Data = [{"name", "Willy"}, {"wrapped", F}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
comments_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"comment.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"comment.result">>])),
Data = [],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
partials_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"partial.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"partial.result">>])),
Data = [{"names", [[{"name", "alice"}], [{"name", "bob"}]]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
delimiter_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"delimiter.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"delimiter.result">>])),
Data = [{"default_tags", "tag1"}, {"erb_style_tags", "tag2"}, {"default_tags_again", "tag3"}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
dot_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"dot.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"dot.result">>])),
Data = [{"mylist", ["Item 1", "Item 2", "Item 3"]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
dot_unescape_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"dot_unescape.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"dot_unescape.result">>])),
Data = [{"mylist", ["Item 1", "Item 2", "Item 3"]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
indent_partials_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"a.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"a.result">>])),
Data = [{"sections", [[{"section", "1st section"}], [{"section", "2nd section"}]]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
not_found_partials_ct1(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"not_found_partial.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"not_found_partial.result">>])),
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))([])), ?config2(options, Config, []))).
not_found_partials_ct2(Config) ->
?assertError({file_not_found, <<"does_not_exist_template">>, enoent},
bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"not_found_partial.mustache">>]),
[raise_on_partial_miss])).
not_found_partials_ct3(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"not_found_partial.mustache">>])),
?assertError({context_missing, {file_not_found, <<"does_not_exist_template">>}},
bbmustache:compile(Template, ?debug((?config(data_conv, Config))([])),
?config2(options, Config, []) ++ [raise_on_context_miss])).
context_stack_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"context.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"context.result">>])),
Data = [{"a", [{"A", [{"1", "&"}]}]}, {"b", [{"B", [{"2", "<"}]}]}, {"c", [{"C", [{"3", ">"}]}]}],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
context_stack_ct2(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"context2.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"context2.result">>])),
Data = [
{"items", [[{"item", 1}], [{"item", 2}], [{"item", 3}]]},
{"a", [{"b", ["A", "B", "C"]}]}
],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data)), ?config2(options, Config, []))).
partial_custom_reader_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"not_found_partial.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"not_found_partial.result">>])),
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))([])),
?config2(options, Config, []) ++ [{partial_file_reader, fun(_, Key) -> Key end}])).
-ifdef(unicode_supported).
unicode_render_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"unicode.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"unicode.result">>])),
Data1 = [
{"whoami", "猫"},
{"name", "まだない"}
],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data1)), ?config2(options, Config, []))),
Data2 = [
{"whoami", <<"猫"/utf8>>},
{"name", <<"まだない"/utf8>>}
],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data2)), ?config2(options, Config, []))),
Data3 = [
{"whoami", '猫'},
{"name", 'まだない'}
],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data3)), ?config2(options, Config, []))).
-else.
unicode_render_ct(Config) ->
Template = bbmustache:parse_file(filename:join([?config(data_dir, Config), <<"unicode.mustache">>])),
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), <<"unicode.result">>])),
Data1 = [
{"whoami", "猫"},
{"name", "まだない"}
],
?assertEqual(File, bbmustache:compile(Template, ?debug((?config(data_conv, Config))(Data1)), ?config2(options, Config, []))).
-endif.
%%----------------------------------------------------------------------------------------------------------------------
%% Internal Functions
%%----------------------------------------------------------------------------------------------------------------------
%% @doc Recursively converted `map' into `assoc list'.
list_to_maps_recursive([{_, _} | _] = AssocList) ->
lists:foldl(fun({Key, [{_, _} | _] = Value}, Map) ->
maps:put(Key, list_to_maps_recursive(Value), Map);
({Key, Value}, Map) when is_list(Value) ->
maps:put(Key, [list_to_maps_recursive(X) || X <- Value], Map);
({Key, Value}, Map) ->
maps:put(Key, Value, Map)
end, maps:new(), AssocList);
list_to_maps_recursive(Other) ->
Other.
%% @doc Convert `map' into `assoc list' that exist at the specified depth.
-spec deps_list_to_maps([{term(), term()}], Deps :: pos_integer()) -> [{term(), term()}] | #{}.
deps_list_to_maps(AssocList, 1) ->
maps:from_list(AssocList);
deps_list_to_maps(AssocList, Deps) when Deps > 1 ->
R = lists:foldl(fun({Key, [{_, _} | _] = Value}, Acc) ->
[{Key, deps_list_to_maps(Value, Deps - 1)} | Acc];
({Key, Value}, Acc) ->
[{Key, Value} | Acc]
end, [], AssocList),
lists:reverse(R).
%% @doc Recursively converted keys in assoc list.
key_conv_recursive([{_, _} | _] = AssocList, ConvFun) ->
lists:foldl(fun({Key, [{_, _} | _] = Value}, Acc) ->
[{ConvFun(Key), key_conv_recursive(Value, ConvFun)} | Acc];
({Key, Value}, Acc) when is_list(Value) ->
[{ConvFun(Key), [key_conv_recursive(X, ConvFun) || X <- Value]} | Acc];
({Key, Value}, Acc) ->
[{ConvFun(Key), Value} | Acc]
end, [], AssocList);
key_conv_recursive(Other, _) ->
Other.
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/ 0000775 0000000 0000000 00000000000 14143115056 0021645 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/a.mustache 0000664 0000000 0000000 00000000071 14143115056 0023616 0 ustar 00root root 0000000 0000000 {{# sections }}
{{ section }}
{{>b}}
{{/ sections }}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/a.result 0000664 0000000 0000000 00000000276 14143115056 0023332 0 ustar 00root root 0000000 0000000 1st section
1st section
Hello, indent paritals !
2nd line
3rd line
2nd section
2nd section
Hello, indent paritals !
2nd line
3rd line
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/b.mustache 0000664 0000000 0000000 00000000030 14143115056 0023612 0 ustar 00root root 0000000 0000000 {{ section }}
{{>c}} erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/c.mustache 0000664 0000000 0000000 00000000053 14143115056 0023620 0 ustar 00root root 0000000 0000000 Hello, indent paritals !
2nd line
3rd line
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/comment.mustache 0000664 0000000 0000000 00000000040 14143115056 0025034 0 ustar 00root root 0000000 0000000 Today{{! ignore me }}.
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/comment.result 0000664 0000000 0000000 00000000020 14143115056 0024537 0 ustar 00root root 0000000 0000000 Today.
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/context.mustache 0000664 0000000 0000000 00000000556 14143115056 0025072 0 ustar 00root root 0000000 0000000 {{ a.A.1 }}:{{ b.B.2 }}:{{ c.C.3 }}
{{{ a.A.1 }}}:{{{ b.B.2 }}}:{{{ c.C.3 }}}
{{#a}}
{{ A.1 }}:{{ B.2 }}:{{ b.B.2 }}
{{{ A.1 }}}:{{{ B.2 }}}:{{{ b.B.2 }}}
{{#A}}
{{ 1 }}:{{ A.1 }}:{{ B.2 }}:{{ b.B.2 }}
{{{ 1 }}}:{{{ A.1 }}}:{{{ B.2 }}}:{{{ b.B.2 }}}
{{#b}}
{{ 1 }}:{{ A.1 }}:{{ B.2 }}:{{ b.B.2 }}
{{{ 1 }}}:{{{ A.1 }}}:{{{ B.2 }}}:{{{ b.B.2 }}}
{{/b}}
{{/A}}
{{/a}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/context.result 0000664 0000000 0000000 00000000136 14143115056 0024571 0 ustar 00root root 0000000 0000000 &:<:>
&:<:>
&::<
&::<
&:&::<
&:&::<
&:&:<:<
&:&:<:<
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/context2.mustache 0000664 0000000 0000000 00000000050 14143115056 0025141 0 ustar 00root root 0000000 0000000 {{#items}}
{{item}}. {{a.b}}
{{/items}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/context2.result 0000664 0000000 0000000 00000000025 14143115056 0024650 0 ustar 00root root 0000000 0000000 1. ABC
2. ABC
3. ABC
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/delimiter.mustache 0000664 0000000 0000000 00000000135 14143115056 0025355 0 ustar 00root root 0000000 0000000 * {{default_tags}}
{{=<% %>=}}
* <% erb_style_tags %>
<%={{ }}=%>
* {{ default_tags_again }}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/delimiter.result 0000664 0000000 0000000 00000000025 14143115056 0025060 0 ustar 00root root 0000000 0000000 * tag1
* tag2
* tag3
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/dot.mustache 0000664 0000000 0000000 00000000035 14143115056 0024164 0 ustar 00root root 0000000 0000000 {{#mylist}}
{{.}}
{{/mylist}} erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/dot.result 0000664 0000000 0000000 00000000116 14143115056 0023671 0 ustar 00root root 0000000 0000000 <b>Item 1</b>
<b>Item 2</b>
<b>Item 3</b>
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/dot_unescape.mustache 0000664 0000000 0000000 00000000037 14143115056 0026051 0 ustar 00root root 0000000 0000000 {{#mylist}}
{{{.}}}
{{/mylist}} erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/dot_unescape.result 0000664 0000000 0000000 00000000052 14143115056 0025553 0 ustar 00root root 0000000 0000000 Item 1
Item 2
Item 3
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/false_values.mustache 0000664 0000000 0000000 00000000054 14143115056 0026050 0 ustar 00root root 0000000 0000000 Shown.
{{#person}}
Never shown!
{{/person}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/false_values.result 0000664 0000000 0000000 00000000007 14143115056 0025553 0 ustar 00root root 0000000 0000000 Shown.
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/invarted.mustache 0000664 0000000 0000000 00000000103 14143115056 0025206 0 ustar 00root root 0000000 0000000 {{#repo}}
{{name}}
{{/repo}}
{{^repo}}
No repos :(
{{/repo}} erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/invarted.result 0000664 0000000 0000000 00000000014 14143115056 0024714 0 ustar 00root root 0000000 0000000 No repos :(
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/lambdas.mustache 0000664 0000000 0000000 00000000055 14143115056 0025003 0 ustar 00root root 0000000 0000000 {{#wrapped}}{{name}} is awesome.{{/wrapped}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/lambdas.result 0000664 0000000 0000000 00000000031 14143115056 0024502 0 ustar 00root root 0000000 0000000 Willy is awesome.
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/non-empty.mustache 0000664 0000000 0000000 00000000044 14143115056 0025324 0 ustar 00root root 0000000 0000000 {{#repo}}
{{name}}
{{/repo}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/non-empty.result 0000664 0000000 0000000 00000000044 14143115056 0025031 0 ustar 00root root 0000000 0000000 resque
hub
rip
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/non-false.mustache 0000664 0000000 0000000 00000000047 14143115056 0025263 0 ustar 00root root 0000000 0000000 {{#person?}}
Hi {{name}}!
{{/person?}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/non-false.result 0000664 0000000 0000000 00000000010 14143115056 0024756 0 ustar 00root root 0000000 0000000 Hi Jon!
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/not_found_partial.mustache 0000664 0000000 0000000 00000000114 14143115056 0027103 0 ustar 00root root 0000000 0000000 It is not_found_partial.mustache.
begin
{{> does_not_exist_template}}
end
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/not_found_partial.result 0000664 0000000 0000000 00000000054 14143115056 0026613 0 ustar 00root root 0000000 0000000 It is not_found_partial.mustache.
begin
end
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/partial.mustache 0000664 0000000 0000000 00000000056 14143115056 0025035 0 ustar 00root root 0000000 0000000 Names
{{#names}}{{> user}}{{/names}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/partial.result 0000664 0000000 0000000 00000000074 14143115056 0024542 0 ustar 00root root 0000000 0000000 Names
alice
bob
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/partial_custom_reader.mustache 0000664 0000000 0000000 00000000120 14143115056 0027741 0 ustar 00root root 0000000 0000000 It is partial_custom_reader.mustache.
begin
{{> does_not_exist_template}}
end
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/partial_custom_reader.result 0000664 0000000 0000000 00000000112 14143115056 0027447 0 ustar 00root root 0000000 0000000 It is partial_custom_reader.mustache.
begin
does_not_exist_template
end
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/unicode.mustache 0000664 0000000 0000000 00000000055 14143115056 0025026 0 ustar 00root root 0000000 0000000 吾輩は{{whoami}}である名前は{{name}} erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/unicode.result 0000664 0000000 0000000 00000000052 14143115056 0024530 0 ustar 00root root 0000000 0000000 吾輩は猫である名前はまだない erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/user.mustache 0000664 0000000 0000000 00000000032 14143115056 0024351 0 ustar 00root root 0000000 0000000 {{name}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/variables.mustache 0000664 0000000 0000000 00000000057 14143115056 0025352 0 ustar 00root root 0000000 0000000 *{{name}}
*{{age}}
*{{company}}
*{{{company}}}
erlang-bbmustache-1.12.2/ct/bbmustache_SUITE_data/variables.result 0000664 0000000 0000000 00000000063 14143115056 0025054 0 ustar 00root root 0000000 0000000 *Chris
*
*<b>GitHub</b>
*GitHub
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE.erl 0000664 0000000 0000000 00000012650 14143115056 0023115 0 ustar 00root root 0000000 0000000 %% @copyright 2020 Hinagiku Soranoba All Rights Reserved.
-module(bbmustache_escript_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
%%----------------------------------------------------------------------------------------------------------------------
%% 'common_test' Callback API
%%----------------------------------------------------------------------------------------------------------------------
all() ->
[
{group, long},
{group, short},
{group, with_args},
help, all_key_and_format_type, multiple_data_files, enoent
].
groups() ->
[
{long, [version, help, key_type]},
{short, [version, help, key_type]},
{with_args, [version, help]}
].
init_per_suite(Config) ->
Escript = case os:getenv("CMD_TOOL") of
Path when is_list(Path) -> Path
end,
[{escript, Escript} | Config].
end_per_suite(_) ->
ok.
init_per_testcase(TestCase, Config) ->
Args = case {group_name(Config), TestCase} of
{long, version} -> ["--version"];
{short, version} -> ["-v"];
{with_args, version} -> ["-v", "file"];
{long, help} -> ["--help"];
{short, help} -> ["-h"];
{with_args, help} -> ["-h", "file"];
{undefined, help} -> [];
{long, key_type} -> ["--key-type", "atom",
"--data-file", data_file_name(atom, basic, Config),
?config(data_dir, Config) ++ "template.mustache"];
{short, key_type} -> ["-k", "atom",
"-d", data_file_name(atom, basic, Config),
?config(data_dir, Config) ++ "template.mustache"];
_ -> []
end,
[{args, Args} | Config].
end_per_testcase(_, _) ->
ok.
%%----------------------------------------------------------------------------------------------------------------------
%% Common Test Functions
%%----------------------------------------------------------------------------------------------------------------------
version(Config) ->
Got = run(Config),
?assertMatch({match, _}, re:run(Got, "bbmustache v[0-9]+\.[0-9]+\.[0-9]+.*")).
help(Config) ->
Got = run(Config),
?assertMatch({match, _}, re:run(Got, "Usage: .*")).
key_type(Config) ->
Got = run(Config),
Expect = read_file("template.result", Config),
?assertEqual(Expect, Got).
all_key_and_format_type(Config) ->
KeyTypes = [atom, string, binary, undefined],
FormatTypes = [basic, assoc, maps],
Expect = read_file("template.result", Config),
TempalteFile = ?config(data_dir, Config) ++ "template.mustache",
ok = lists:foreach(fun({KeyType, FormatType}) ->
ct:log("KeyType = ~p, FormatType = ~p", [KeyType, FormatType]),
Got = run(Config, options(KeyType, FormatType, Config) ++ [TempalteFile]),
?assertEqual(Expect, Got)
end, [{K, F} || K <- KeyTypes, F <- FormatTypes]).
multiple_data_files(Config) ->
KeyTypes = [atom, string, binary, undefined],
FormatTypes = [basic, assoc, maps],
Expect = read_file("template.overlay.result", Config),
TempalteFile = ?config(data_dir, Config) ++ "template.mustache",
ok = lists:foreach(fun({KeyType, FormatType}) ->
ct:log("KeyType = ~p, FormatType = ~p", [KeyType, FormatType]),
Got = run(Config, options(KeyType, FormatType, Config)
++ ["-d", data_file_name(KeyType, overlays, Config)] ++ [TempalteFile]),
?assertEqual(Expect, Got)
end, [{K, F} || K <- KeyTypes, F <- FormatTypes]).
enoent(Config) ->
Got0 = run(Config, ["-d", "no_file", ?config(data_dir, Config) ++ "template.mustache"]),
?assertEqual(<<"ERROR: no_file is unable to read. (enoent)\n">>, Got0),
Got1 = run(Config, ["no_file"]),
?assertEqual(<<"ERROR: no_file is unable to read.\n">>, Got1).
%%----------------------------------------------------------------------------------------------------------------------
%% Internal Functions
%%----------------------------------------------------------------------------------------------------------------------
-spec group_name([term()]) -> atom().
group_name(Config) ->
proplists:get_value(name, ?config(tc_group_properties, Config)).
-spec run([term()]) -> binary().
run(Config) ->
run(Config, []).
-spec run([term()], [string()]) -> binary().
run(Config, Args) ->
Cmd = ?config(escript, Config) ++ " " ++ string:join(?config(args, Config) ++ Args, " "),
ct:log("$ ~s", [Cmd]),
Ret = os:cmd(Cmd),
ct:log("~s", [Ret]),
list_to_binary(Ret).
-spec read_file(file:filename_all(), [term()]) -> binary().
read_file(FileName, Config) ->
{ok, File} = file:read_file(filename:join([?config(data_dir, Config), FileName])),
File.
-spec data_file_name(atom(), atom(), [term()]) -> string().
data_file_name(undefined, FormatType, Config) ->
data_file_name(string, FormatType, Config);
data_file_name(KeyType, FormatType, Config) ->
?config(data_dir, Config) ++ atom_to_list(KeyType) ++ "." ++ atom_to_list(FormatType).
-spec options(atom(), atom(), [term()]) -> [string()].
options(undefined, FormatType, Config) ->
["-d", data_file_name(string, FormatType, Config)];
options(KeyType, FormatType, Config) ->
["-k", atom_to_list(KeyType),
"-d", data_file_name(KeyType, FormatType, Config)].
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/ 0000775 0000000 0000000 00000000000 14143115056 0023376 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/atom.assoc 0000664 0000000 0000000 00000000141 14143115056 0025364 0 ustar 00root root 0000000 0000000 [
{name, "mustache"},
"atom.include",
{data, [
"a",
"b"
]}
].
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/atom.basic 0000664 0000000 0000000 00000000125 14143115056 0025337 0 ustar 00root root 0000000 0000000 {name, "mustache"}.
"atom.include".
{data, [
"a",
"b"
]}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/atom.include 0000664 0000000 0000000 00000000025 14143115056 0025700 0 ustar 00root root 0000000 0000000 {name, "bbmustache"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/atom.maps 0000664 0000000 0000000 00000000125 14143115056 0025216 0 ustar 00root root 0000000 0000000 #{
name => "bbmustache",
data => [
"a",
"b"
]
}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/atom.overlays 0000664 0000000 0000000 00000000023 14143115056 0026117 0 ustar 00root root 0000000 0000000 {name, "overlays"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/binary.assoc 0000664 0000000 0000000 00000000201 14143115056 0025705 0 ustar 00root root 0000000 0000000 [
{<<"name">>, "mustache"},
"binary.include",
{<<"data">>, [
"a",
"b"
]}
].
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/binary.basic 0000664 0000000 0000000 00000000163 14143115056 0025665 0 ustar 00root root 0000000 0000000 {<<"name">>, "mustache"}.
"binary.include".
{<<"data">>, [
"a",
"b"
]}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/binary.include 0000664 0000000 0000000 00000000033 14143115056 0026223 0 ustar 00root root 0000000 0000000 {<<"name">>, "bbmustache"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/binary.maps 0000664 0000000 0000000 00000000163 14143115056 0025544 0 ustar 00root root 0000000 0000000 #{
<<"name">> => "bbmustache",
<<"data">> => [
"a",
"b"
]
}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/binary.overlays 0000664 0000000 0000000 00000000031 14143115056 0026442 0 ustar 00root root 0000000 0000000 {<<"name">>, "overlays"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/partial.mustache 0000664 0000000 0000000 00000000120 14143115056 0026556 0 ustar 00root root 0000000 0000000 {{name}} is Binary pattern match Based Mustache template engine for Erlang/OTP.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/string.assoc 0000664 0000000 0000000 00000000155 14143115056 0025737 0 ustar 00root root 0000000 0000000 [
{"name", "mustache"},
"string.include",
{"data", [
"a",
"b"
]}
].
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/string.basic 0000664 0000000 0000000 00000000137 14143115056 0025710 0 ustar 00root root 0000000 0000000 {"name", "mustache"}.
"string.include".
{"data", [
"a",
"b"
]}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/string.include 0000664 0000000 0000000 00000000027 14143115056 0026250 0 ustar 00root root 0000000 0000000 {"name", "bbmustache"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/string.maps 0000664 0000000 0000000 00000000137 14143115056 0025567 0 ustar 00root root 0000000 0000000 #{
"name" => "bbmustache",
"data" => [
"a",
"b"
]
}.
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/string.overlays 0000664 0000000 0000000 00000000025 14143115056 0026467 0 ustar 00root root 0000000 0000000 {"name", "overlays"}. erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/template.mustache 0000664 0000000 0000000 00000000167 14143115056 0026750 0 ustar 00root root 0000000 0000000 The engine name ie {{name}}.
It can also resolve relative paths.
{{> partial}}
data:
{{# data}}
- {{.}}
{{/ data}} erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/template.overlay.result 0000664 0000000 0000000 00000000246 14143115056 0030133 0 ustar 00root root 0000000 0000000 The engine name ie overlays.
It can also resolve relative paths.
overlays is Binary pattern match Based Mustache template engine for Erlang/OTP.
data:
- a
- b
erlang-bbmustache-1.12.2/ct/bbmustache_escript_SUITE_data/template.result 0000664 0000000 0000000 00000000252 14143115056 0026450 0 ustar 00root root 0000000 0000000 The engine name ie bbmustache.
It can also resolve relative paths.
bbmustache is Binary pattern match Based Mustache template engine for Erlang/OTP.
data:
- a
- b
erlang-bbmustache-1.12.2/ct/bbmustache_eunit_SUITE.erl 0000664 0000000 0000000 00000001540 14143115056 0022564 0 ustar 00root root 0000000 0000000 %% @copyright 2015 Hinagiku Soranoba All Rights Reserved.
-module(bbmustache_eunit_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-export([
all/0, eunit_ct/1
]).
%%----------------------------------------------------------------------------------------------------------------------
%% 'common_test' Callback API
%%----------------------------------------------------------------------------------------------------------------------
all() ->
[eunit_ct].
%%----------------------------------------------------------------------------------------------------------------------
%% Common Test Functions
%%----------------------------------------------------------------------------------------------------------------------
eunit_ct(_Config) ->
ok = eunit:test({application, bbmustache}).
erlang-bbmustache-1.12.2/ct/bbmustache_spec_SUITE.erl 0000664 0000000 0000000 00000006226 14143115056 0022400 0 ustar 00root root 0000000 0000000 %% @copyright 2016 Hinagiku Soranoba All Rights Reserved.
%%
%% This common test is checked that bbmustache meets the reference implementation.
%%
%% Reference implementation:
%% https://github.com/mustache/spec
%%
-module(bbmustache_spec_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-define(SKIP_FILES, [
% e.g. "name.json"
"~lambdas.json",
"~inheritance.json"
]).
-define(SKIP_CASES, [
% e.g. {"name.json", <<"Test Case">>}
]).
%%----------------------------------------------------------------------------------------------------------------------
%% 'common_test' Callback API
%%----------------------------------------------------------------------------------------------------------------------
all() ->
[specs].
specs(Config) ->
Jsons = case filelib:wildcard("../../**/mustache_spec.app") of
[AppPath | _] ->
filelib:wildcard(filename:join([filename:absname(filename:dirname(AppPath)), "..", "specs", "*.json"]));
[] ->
ct:log("mustache_spec.app is not found. please check the deps."),
?assert(spec_is_not_found)
end,
%% NOTE: priv_dir did write partial files.
ok = file:set_cwd(?config(priv_dir, Config)),
lists:foreach(fun ?MODULE:spec_tests/1, Jsons).
spec_tests(JsonPath) ->
ct:log("---- ~s -----", [Basename = filename:basename(JsonPath)]),
case lists:member(Basename, ?SKIP_FILES) of
true ->
ct:log("This test case did skip...");
false ->
{ok, JsonBin} = file:read_file(JsonPath),
JsonDec = jsone:decode(JsonBin, [{object_format, proplist}]),
Tests0 = proplists:get_value(<<"tests">>, JsonDec),
SkipTests = proplists:get_all_values(Basename, ?SKIP_CASES),
Tests = lists:foldl(
fun(T, Acc) ->
case lists:member(proplists:get_value(<<"name">>, T), SkipTests) of
true -> Acc;
false -> [T | Acc]
end
end, [], lists:reverse(Tests0)),
lists:foreach(fun ?MODULE:spec_test/1, Tests)
end.
spec_test(Assoc) ->
Name = proplists:get_value(<<"name">>, Assoc),
Data = proplists:get_value(<<"data">>, Assoc),
Expected = proplists:get_value(<<"expected">>, Assoc),
Template = proplists:get_value(<<"template">>, Assoc),
Partials = proplists:get_value(<<"partials">>, Assoc, []),
ok = clean_dir("."),
ok = lists:foreach(fun ?MODULE:write_file/1, Partials),
ct:log("CASE: ~s", [Name]),
?assertEqual(Expected, bbmustache:render(Template, Data, [{key_type, binary}])).
clean_dir(Dir) ->
lists:foreach(fun(F) -> file:delete(F) end,
filelib:wildcard(filename:join(Dir, "*.mustache"))).
write_file({PartialFilename, PartialData}) ->
ok = file:write_file(<>, PartialData);
write_file(_) ->
ok.
erlang-bbmustache-1.12.2/doc/ 0000775 0000000 0000000 00000000000 14143115056 0015725 5 ustar 00root root 0000000 0000000 erlang-bbmustache-1.12.2/doc/README.md 0000664 0000000 0000000 00000000276 14143115056 0017211 0 ustar 00root root 0000000 0000000
# The bbmustache application #
## Modules ##
erlang-bbmustache-1.12.2/doc/bbmustache.md 0000664 0000000 0000000 00000021165 14143115056 0020371 0 ustar 00root root 0000000 0000000
# Module bbmustache #
* [Description](#description)
* [Data Types](#types)
* [Function Index](#index)
* [Function Details](#functions)
Binary pattern match Based Mustach template engine for Erlang/OTP.
Copyright (c) 2015 Hinagiku Soranoba All Rights Reserved.
## Description ##
Please refer to [the man page](http://mustache.github.io/mustache.5.html) and [the spec](https://github.com/mustache/spec) of mustache as the need arises.
Please see [this](../benchmarks/README.md) for a list of features that bbmustache supports.
## Data Types ##
### compile_option() ###
compile_option() = {key_type, atom | binary | string} | raise_on_context_miss | {escape_fun, fun((binary()) -> binary())} | {value_serializer, fun((any()) -> iodata())}
|key |description |
|:-- |:---------- |
|key_type | Specify the type of the key in [`data/0`](#data-0). Default value is `string`. |
|raise_on_context_miss| If key exists in template does not exist in data, it will throw an exception (error).|
|escape_fun | Specify your own escape function. |
|value_serializer | specify how terms are converted to iodata when templating. |
### data() ###
data() = term()
Beginners should consider [`data/0`](#data-0) as [`recursive_data/0`](#recursive_data-0).
By specifying options, the type are greatly relaxed and equal to `term/0`.
### data_key() ###
data_key() = atom() | binary() | string()
You can choose one from these as the type of key in [`recursive_data/0`](#recursive_data-0).
The default is `string/0`.
If you want to change this, you need to specify `key_type` in [`compile_option/0`](#compile_option-0).
### key() ###
key() = binary()
Key MUST be a non-whitespace character sequence NOT containing the current closing delimiter.
In addition, `.` have a special meaning.
(1) `parent.child` ... find the child in the parent.
(2) `.` ... It means current context.
### option() ###
option() = compile_option()
This type has been deprecated since 1.6.0. It will remove in 2.0.0.
### parse_option() ###
parse_option() = {partial_file_reader, fun((Dirname::binary(), key()) -> Data::binary())} | raise_on_partial_miss
|key |description |
|:-- |:---------- |
|partial_file_reader | When you specify this, it delegate reading of file to the function by `partial`.
This can be used when you want to read from files other than local files.|
|raise_on_partial_miss| If the template used in partials does not found, it will throw an exception (error). |
### recursive_data() ###
recursive_data() = [{data_key(), term()}]
### render_option() ###
render_option() = compile_option() | parse_option()
### template() ###
__abstract datatype__: `template()`
## Function Index ##
## Function Details ##
### compile/2 ###
compile(Template::template(), Data::data()) -> binary()
Equivalent to [`compile(Template, Data, [])`](#compile-3).
### compile/3 ###
compile(Bbmustache::template(), Data::data(), Options::[compile_option()]) -> binary()
Embed the data in the template.
```
1> Template = bbmustache:parse_binary(<<"{{name}}">>).
2> bbmustache:compile(Template, #{"name" => "Alice"}).
<<"Alice">>
```
Data support an associative array or a map.
All keys MUST be same type.
### default_partial_file_reader/2 ###
default_partial_file_reader(Dirname::binary(), Key::binary()) -> {ok, binary()} | {error, Reason::term()}
Default partial file reader
### default_value_serializer/1 ###
default_value_serializer(Integer::number() | binary() | string() | atom()) -> iodata()
Default value serializer for templtated values
### parse_binary/1 ###
parse_binary(Bin::binary()) -> template()
Equivalent to [`parse_binary(Bin, [])`](#parse_binary-2).
### parse_binary/2 ###
parse_binary(Bin::binary(), Options::[parse_option()]) -> template()
Create a [`template/0`](#template-0) from a binary.
### parse_file/1 ###
parse_file(Filename::file:filename_all()) -> template()
Equivalent to [`parse_file(Filename, [])`](#parse_file-2).
### parse_file/2 ###
parse_file(Filename::file:filename_all(), Options::[parse_option()]) -> template()
Create a [`template/0`](#template-0) from a file.
### render/2 ###
render(Bin::binary(), Data::data()) -> binary()
Equivalent to [`render(Bin, Data, [])`](#render-3).
__See also:__ [compile/2](#compile-2), [compile_option/0](#compile_option-0), [compile_option/0](#compile_option-0), [parse_binary/1](#parse_binary-1), [parse_file/1](#parse_file-1), [parse_option/0](#parse_option-0), [render/2](#render-2).
### render/3 ###
render(Bin::binary(), Data::data(), Options::[render_option()]) -> binary()
Equivalent to [`compile(parse_binary(Bin), Data, Options)`](#compile-3).
erlang-bbmustache-1.12.2/rebar.config 0000664 0000000 0000000 00000004056 14143115056 0017447 0 ustar 00root root 0000000 0000000 %% vim: set filetype=erlang : -*- erlang -*-
{erl_opts, [
{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^20", unicode_supported},
warnings_as_errors,
warn_export_all,
warn_untyped_record
]}.
{xref_checks, [
fail_on_warning,
undefined_function_calls
]}.
{cover_enabled, true}.
{edoc_opts, [
{doclet, edown_doclet},
{app_default, "http://www.erlang.org/doc/man"},
{dialyzer_specs, all},
{report_missing_type, true},
{report_type_mismatch, true},
{pretty_print, erl_pp},
{preprocess, true}
]}.
{validate_app_modules, true}.
{ct_opts, [{dir, "ct"}]}.
{git_vsn, [{env_key, git_vsn},
{describe_opt, "--tags --abbrev=10"},
{separate, true}]}.
{escript_name, bbmustache}.
{escript_incl_apps, [getopt]}.
{escript_comment, "%% https://github.com/soranoba/bbmustache \n"}.
{profiles, [{test, [{erl_opts, [export_all]},
{deps,
[
{jsone, "1.4.6"},
{mustache_spec, ".*", {git, "git://github.com/soranoba/spec.git", {tag, "v1.2.1-erl"}}}
]},
{plugins, [rebar3_raw_deps]}
]},
{dev, [{erl_opts, [{d, bbmustache_escriptize}]},
{deps,
[
{getopt, "1.0.1"}
]},
{plugins, [rebar3_git_vsn]},
{provider_hooks, [{post, [{compile, git_vsn}]}]}
]},
{doc, [{deps,
[
{edown, ".*", {git, "git://github.com/uwiger/edown.git", {tag, "0.8.3"}}}
]}
]},
{bench, [{deps,
[
{mustache, ".*", {git, "git://github.com/mojombo/mustache.erl", {tag, "v0.1.1"}}}
]}
]}
]}.
erlang-bbmustache-1.12.2/rebar.lock 0000664 0000000 0000000 00000000004 14143115056 0017117 0 ustar 00root root 0000000 0000000 [].
erlang-bbmustache-1.12.2/rebar3 0000775 0000000 0000000 00002545255 14143115056 0016306 0 ustar 00root root 0000000 0000000 #!/usr/bin/env escript
%%
%%! +sbtu +A1
PK ivLٳ bbmustache/ebin/bbmustache.appmP=k0+faCt-4pa$s*%uVQB~f[}K[bH*&V2j5P>:T#1Krc~? j=<50H`D6\BglXb*d+eFp+⎜߿WbѓHm;Lm|hoӇaq+nc7PK ivLw^ / bbmustache/ebin/bbmustache.beam|X]xՙcᓌ;#%M7y9~Ό?PhL~19
BSWj{UnwSF fj*Fy:0]k5m^Us^ѩ5|QTvܘt^^6_ՎBdu֨NkkD5lu:hz_"f}>8U';X^xkWo5f]:]aZ#(flS
iQix6Eׯ6rLKh#:7h`+kV"ӓJvc[o6[{2Q\EvZռj;܁/AKL\E tlTMyuNۋ*04]_m;yӏW:C=M馮gչ xU 1@jCwh6k7 ʵRƯUZsjpF Zs=D3'pP#v"or&