mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Fix #187 (rename mustache to rebar_mustache)
This commit is contained in:
parent
777fefe181
commit
34ead92c83
3 changed files with 8 additions and 6 deletions
|
@ -39,7 +39,7 @@
|
||||||
rebar_utils,
|
rebar_utils,
|
||||||
rebar_xref,
|
rebar_xref,
|
||||||
rebar_getopt,
|
rebar_getopt,
|
||||||
mustache ]},
|
rebar_mustache ]},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel,
|
{applications, [kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
%% See the README at http://github.com/mojombo/mustache.erl for additional
|
%% See the README at http://github.com/mojombo/mustache.erl for additional
|
||||||
%% documentation and usage examples.
|
%% documentation and usage examples.
|
||||||
|
|
||||||
-module(mustache). %% v0.1.0
|
-module(rebar_mustache). %% v0.1.0
|
||||||
-author("Tom Preston-Werner").
|
-author("Tom Preston-Werner").
|
||||||
-export([compile/1, compile/2, render/1, render/2, render/3, get/2, get/3, escape/1, start/1]).
|
-export([compile/1, compile/2, render/1, render/2, render/3, get/2, get/3, escape/1, start/1]).
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
||||||
section_re = undefined,
|
section_re = undefined,
|
||||||
tag_re = undefined}).
|
tag_re = undefined}).
|
||||||
|
|
||||||
|
-define(MUSTACHE_STR, "rebar_mustache").
|
||||||
|
|
||||||
compile(Body) when is_list(Body) ->
|
compile(Body) when is_list(Body) ->
|
||||||
State = #mstate{},
|
State = #mstate{},
|
||||||
CompiledTemplate = pre_compile(Body, State),
|
CompiledTemplate = pre_compile(Body, State),
|
||||||
|
@ -108,7 +110,7 @@ compile_section(Name, Content, State) ->
|
||||||
Mod = State#mstate.mod,
|
Mod = State#mstate.mod,
|
||||||
Result = compiler(Content, State),
|
Result = compiler(Content, State),
|
||||||
"fun() -> " ++
|
"fun() -> " ++
|
||||||
"case mustache:get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
"case " ++ ?MUSTACHE_STR ++ ":get(" ++ Name ++ ", Ctx, " ++ atom_to_list(Mod) ++ ") of " ++
|
||||||
"\"true\" -> " ++
|
"\"true\" -> " ++
|
||||||
Result ++ "; " ++
|
Result ++ "; " ++
|
||||||
"\"false\" -> " ++
|
"\"false\" -> " ++
|
||||||
|
@ -143,10 +145,10 @@ tag_kind(T, {K0, K1}) ->
|
||||||
|
|
||||||
compile_tag(none, Content, State) ->
|
compile_tag(none, Content, State) ->
|
||||||
Mod = State#mstate.mod,
|
Mod = State#mstate.mod,
|
||||||
"mustache:escape(mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
?MUSTACHE_STR ++ ":escape(" ++ ?MUSTACHE_STR ++ ":get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ "))";
|
||||||
compile_tag("{", Content, State) ->
|
compile_tag("{", Content, State) ->
|
||||||
Mod = State#mstate.mod,
|
Mod = State#mstate.mod,
|
||||||
"mustache:get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
|
?MUSTACHE_STR ++ ":get(" ++ Content ++ ", Ctx, " ++ atom_to_list(Mod) ++ ")";
|
||||||
compile_tag("!", _Content, _State) ->
|
compile_tag("!", _Content, _State) ->
|
||||||
"[]".
|
"[]".
|
||||||
|
|
|
@ -103,7 +103,7 @@ render(Bin, Context) ->
|
||||||
ReOpts = [global, {return, list}],
|
ReOpts = [global, {return, list}],
|
||||||
Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
|
Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
|
||||||
Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
|
Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
|
||||||
mustache:render(Str1, Context).
|
rebar_mustache:render(Str1, Context).
|
||||||
|
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
|
Loading…
Reference in a new issue