summaryrefslogtreecommitdiff
path: root/src/rebar_templater.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_templater.erl')
-rw-r--r--src/rebar_templater.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 43bb8da..4abf404 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -245,7 +245,8 @@ find_disk_templates(Config) ->
HomeFiles = rebar_utils:find_files(filename:join([os:getenv("HOME"),
".rebar", "templates"]),
?TEMPLATE_RE),
- LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE),
+ Recursive = rebar_config:is_recursive(Config),
+ LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE, Recursive),
[{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles].
find_other_templates(Config) ->
@@ -396,6 +397,18 @@ execute_template(Files, [{'if', Cond, True, False} | Rest], TemplateType,
execute_template(Files, prepend_instructions(Instructions, Rest),
TemplateType, TemplateName, Context, Force,
ExistingFiles);
+execute_template(Files, [{'case', Variable, Values, Instructions} | Rest], TemplateType,
+ TemplateName, Context, Force, ExistingFiles) ->
+ {ok, Value} = dict:find(Variable, Context),
+ Instructions2 = case lists:member(Value, Values) of
+ true ->
+ Instructions;
+ _ ->
+ []
+ end,
+ execute_template(Files, prepend_instructions(Instructions2, Rest),
+ TemplateType, TemplateName, Context, Force,
+ ExistingFiles);
execute_template(Files, [{template, Input, Output} | Rest], TemplateType,
TemplateName, Context, Force, ExistingFiles) ->
InputName = filename:join(filename:dirname(TemplateName), Input),