Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:22
bbmustache
bbmustache-1.12.2-git.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bbmustache-1.12.2-git.patch of Package bbmustache
diff --git a/README.md b/README.md index a3af086..6318184 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ A logic-less templates. ### Quick start ```bash -$ git clone git://github.com/soranoba/bbmustache.git +$ git clone https://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] @@ -39,7 +39,7 @@ Add the following settings. {deps, [ - {bbmustache, ".*", {git, "git://github.com/soranoba/bbmustache.git", {branch, "master"}}} + {bbmustache, ".*", {git, "https://github.com/soranoba/bbmustache.git", {branch, "master"}}} ]}. %% rebar3 (rebar.config) diff --git a/benchmarks/README.md b/benchmarks/README.md index 1f1da75..10de0e3 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -3,15 +3,15 @@ |Library|Time | |:------|:-----| -|bbmustache | 39122 | -|mustache.erl | 673416 | +|bbmustache | 18953 | +|mustache.erl | 277171 | # 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 +https://github.com/mustache/spec/tree/v1.2.2/specs/comments.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -29,7 +29,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/comments.yml ## delimiters -https://github.com/mustache/spec/tree/v1.2.1/specs/delimiters.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/delimiters.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -50,7 +50,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/delimiters.yml ## interpolation -https://github.com/mustache/spec/tree/v1.2.1/specs/interpolation.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/interpolation.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -96,7 +96,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/interpolation.yml ## inverted -https://github.com/mustache/spec/tree/v1.2.1/specs/inverted.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/inverted.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -125,7 +125,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/inverted.yml ## partials -https://github.com/mustache/spec/tree/v1.2.1/specs/partials.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/partials.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -143,7 +143,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/partials.yml ## sections -https://github.com/mustache/spec/tree/v1.2.1/specs/sections.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/sections.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -180,7 +180,7 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/sections.yml ## ~inheritance -https://github.com/mustache/spec/tree/v1.2.1/specs/~inheritance.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/~inheritance.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| @@ -205,10 +205,11 @@ https://github.com/mustache/spec/tree/v1.2.1/specs/~inheritance.yml |Multi-level inheritance, no sub child||| |Text inside parent||| |Text inside parent||| +|Block scope||| ## ~lambdas -https://github.com/mustache/spec/tree/v1.2.1/specs/~lambdas.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/~lambdas.yml | |bbmustache|mustache.erl| |:---|:------------|:------------| diff --git a/benchmarks/output.mustache b/benchmarks/output.mustache index 021314c..d3132ee 100644 --- a/benchmarks/output.mustache +++ b/benchmarks/output.mustache @@ -13,7 +13,7 @@ {{# spec_files }} ## {{ spec }} -https://github.com/mustache/spec/tree/v1.2.1/specs/{{ spec }}.yml +https://github.com/mustache/spec/tree/v1.2.2/specs/{{ spec }}.yml | |{{# libraries }}{{ library }}|{{/ libraries }} |:---|{{# libraries }}:------------|{{/ libraries }} diff --git a/doc/bbmustache.md b/doc/bbmustache.md index c80b7d5..52d3ef2 100644 --- a/doc/bbmustache.md +++ b/doc/bbmustache.md @@ -136,7 +136,7 @@ __abstract datatype__: `template()` ## Function Index ## -<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#compile-2">compile/2</a></td><td>Equivalent to <a href="#compile-3"><tt>compile(Template, Data, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#compile-3">compile/3</a></td><td>Embed the data in the template.</td></tr><tr><td valign="top"><a href="#default_partial_file_reader-2">default_partial_file_reader/2</a></td><td>Default partial file reader.</td></tr><tr><td valign="top"><a href="#default_value_serializer-1">default_value_serializer/1</a></td><td>Default value serializer for templtated values.</td></tr><tr><td valign="top"><a href="#parse_binary-1">parse_binary/1</a></td><td>Equivalent to <a href="#parse_binary-2"><tt>parse_binary(Bin, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#parse_binary-2">parse_binary/2</a></td><td>Create a <a docgen-rel="seemfa" docgen-href="#template/0" href="#template-0"><code>template/0</code></a> from a binary.</td></tr><tr><td valign="top"><a href="#parse_file-1">parse_file/1</a></td><td>Equivalent to <a href="#parse_file-2"><tt>parse_file(Filename, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#parse_file-2">parse_file/2</a></td><td>Create a <a docgen-rel="seemfa" docgen-href="#template/0" href="#template-0"><code>template/0</code></a> from a file.</td></tr><tr><td valign="top"><a href="#render-2">render/2</a></td><td>Equivalent to <a href="#render-3"><tt>render(Bin, Data, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#render-3">render/3</a></td><td>Equivalent to <a href="#compile-3"><tt>compile(parse_binary(Bin), Data, Options)</tt></a>.</td></tr></table> +<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#compile-2">compile/2</a></td><td>Equivalent to <a href="#compile-3"><tt>compile(Template, Data, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#compile-3">compile/3</a></td><td>Embed the data in the template.</td></tr><tr><td valign="top"><a href="#default_escape-1">default_escape/1</a></td><td>Default escape function.</td></tr><tr><td valign="top"><a href="#default_partial_file_reader-2">default_partial_file_reader/2</a></td><td>Default partial file reader.</td></tr><tr><td valign="top"><a href="#default_value_serializer-1">default_value_serializer/1</a></td><td>Default value serializer for templtated values.</td></tr><tr><td valign="top"><a href="#parse_binary-1">parse_binary/1</a></td><td>Equivalent to <a href="#parse_binary-2"><tt>parse_binary(Bin, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#parse_binary-2">parse_binary/2</a></td><td>Create a <a href="#template-0"><code>template/0</code></a> from a binary.</td></tr><tr><td valign="top"><a href="#parse_file-1">parse_file/1</a></td><td>Equivalent to <a href="#parse_file-2"><tt>parse_file(Filename, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#parse_file-2">parse_file/2</a></td><td>Create a <a href="#template-0"><code>template/0</code></a> from a file.</td></tr><tr><td valign="top"><a href="#render-2">render/2</a></td><td>Equivalent to <a href="#render-3"><tt>render(Bin, Data, [])</tt></a>.</td></tr><tr><td valign="top"><a href="#render-3">render/3</a></td><td>Equivalent to <a href="#compile-3"><tt>compile(parse_binary(Bin), Data, Options)</tt></a>.</td></tr></table> <a name="functions"></a> @@ -174,6 +174,17 @@ Embed the data in the template. Data support an associative array or a map. <br /> All keys MUST be same type. +<a name="default_escape-1"></a> + +### default_escape/1 ### + +<pre><code> +default_escape(Bin::binary()) -> binary() +</code></pre> +<br /> + +Default escape function. + <a name="default_partial_file_reader-2"></a> ### default_partial_file_reader/2 ### @@ -223,7 +234,7 @@ Create a [`template/0`](#template-0) from a binary. ### parse_file/1 ### <pre><code> -parse_file(Filename::<a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a>) -> <a href="#type-template">template()</a> +parse_file(Filename::<a href="file.md#type-filename_all">file:filename_all()</a>) -> <a href="#type-template">template()</a> </code></pre> <br /> @@ -234,7 +245,7 @@ Equivalent to [`parse_file(Filename, [])`](#parse_file-2). ### parse_file/2 ### <pre><code> -parse_file(Filename::<a href="http://www.erlang.org/doc/man/file.html#type-filename_all">file:filename_all()</a>, Options::[<a href="#type-parse_option">parse_option()</a>]) -> <a href="#type-template">template()</a> +parse_file(Filename::<a href="file.md#type-filename_all">file:filename_all()</a>, Options::[<a href="#type-parse_option">parse_option()</a>]) -> <a href="#type-template">template()</a> </code></pre> <br /> diff --git a/rebar.config b/rebar.config index a14b258..799b629 100644 --- a/rebar.config +++ b/rebar.config @@ -40,7 +40,7 @@ {deps, [ {jsone, "1.4.6"}, - {mustache_spec, ".*", {git, "git://github.com/soranoba/spec.git", {tag, "v1.2.1-erl"}}} + {mustache_spec, ".*", {git, "https://github.com/soranoba/spec.git", {tag, "v1.2.2-erl"}}} ]}, {plugins, [rebar3_raw_deps]} ]}, @@ -54,12 +54,12 @@ ]}, {doc, [{deps, [ - {edown, ".*", {git, "git://github.com/uwiger/edown.git", {tag, "0.8.3"}}} + {edown, ".*", {git, "https://github.com/uwiger/edown.git", {tag, "0.8.3"}}} ]} ]}, {bench, [{deps, [ - {mustache, ".*", {git, "git://github.com/mojombo/mustache.erl", {tag, "v0.1.1"}}} + {mustache, ".*", {git, "https://github.com/mojombo/mustache.erl", {tag, "v0.1.1"}}} ]} ]} ]}. diff --git a/src/bbmustache.erl b/src/bbmustache.erl index 23c6f6a..70f1cb4 100644 --- a/src/bbmustache.erl +++ b/src/bbmustache.erl @@ -21,6 +21,7 @@ parse_file/2, compile/2, compile/3, + default_escape/1, default_value_serializer/1, default_partial_file_reader/2 ]). @@ -239,6 +240,11 @@ compile(#?MODULE{data = Tags} = T, Data, Options) -> Ret = compile_impl(Tags, Data, [], T#?MODULE{options = Options, data = [], context_stack = [Data]}), iolist_to_binary(lists:reverse(Ret)). +%% @doc Default escape function. +-spec default_escape(binary()) -> binary(). +default_escape(Bin) -> + << <<(escape_char(X))/binary>> || <<X:8>> <= Bin >>. + %% @doc Default value serializer for templtated values -spec default_value_serializer(number() | binary() | string() | atom()) -> iodata(). default_value_serializer(Integer) when is_integer(Integer) -> @@ -276,7 +282,7 @@ compile_impl([], _, Result, _) -> compile_impl([{n, Keys} | T], Data, Result, State) -> ValueSerializer = proplists:get_value(value_serializer, State#?MODULE.options, fun default_value_serializer/1), Value = unicode:characters_to_binary(ValueSerializer(get_data_recursive(Keys, Data, <<>>, State))), - EscapeFun = proplists:get_value(escape_fun, State#?MODULE.options, fun escape/1), + EscapeFun = proplists:get_value(escape_fun, State#?MODULE.options, fun default_escape/1), compile_impl(T, Data, ?ADD(EscapeFun(Value), Result), State); compile_impl([{'&', Keys} | T], Data, Result, State) -> ValueSerializer = proplists:get_value(value_serializer, State#?MODULE.options, fun default_value_serializer/1), @@ -614,11 +620,6 @@ to_binary(Bin) when is_binary(Bin) -> to_binary(Bytes) when is_list(Bytes) -> list_to_binary(Bytes). -%% @doc HTML Escape --spec escape(binary()) -> binary(). -escape(Bin) -> - << <<(escape_char(X))/binary>> || <<X:8>> <= Bin >>. - %% @doc escape a character if needed. -spec escape_char(byte()) -> <<_:8, _:_*8>>. escape_char($<) -> <<"<">>; diff --git a/test/bbmustache_tests.erl b/test/bbmustache_tests.erl index d53881d..68f901a 100644 --- a/test/bbmustache_tests.erl +++ b/test/bbmustache_tests.erl @@ -11,9 +11,9 @@ -define(FILE_ERROR, file_not_found). -define(NT_S(X, Y), ?_assertMatch({_, X, _, _, _, _}, bbmustache:parse_binary(Y))). -%% parse_binary_test generater (success case) +%% parse_binary_test generator (success case) -define(NT_F(X, Y), ?_assertError(X, bbmustache:parse_binary(Y))). -%% parse_binary_test generater (failure case) +%% parse_binary_test generator (failure case) parse_file_test_() -> [ @@ -221,7 +221,7 @@ context_stack_test_() -> ?_assertEqual(<<"aaabbb">>, bbmustache:render(<<"{{#parent}}aaa{{parent.child}}bbb{{/parent}}">>, [{"parent", true}]))}, - {"It hide all tags in # tag that is specfied empty list", + {"It hide all tags in # tag that is specified empty list", ?_assertEqual(<<"">>, bbmustache:render(<<"{{#parent}}aaa{{parent.child}}bbb{{/parent}}">>, [{"parent", []}],
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor