From 33110267bae3ff3b0511267016a1915c01e8d287 Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Sun, 2 Feb 2014 21:17:14 +0100 Subject: Adapt erlydtl compiler plugin to latest version of erlydtl --- src/rebar_erlydtl_compiler.erl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl index fea8ea6..ae64bcb 100644 --- a/src/rebar_erlydtl_compiler.erl +++ b/src/rebar_erlydtl_compiler.erl @@ -178,7 +178,7 @@ compile_dtl(Config, Source, Target, DtlOpts) -> ?ERROR("~n===============================================~n" " You need to install erlydtl to compile DTL templates~n" " Download the latest tarball release from github~n" - " http://code.google.com/p/erlydtl/~n" + " https://github.com/erlydtl/erlydtl/releases~n" " and install it into your erlang library dir~n" "===============================================~n~n", []), ?FAIL; @@ -194,6 +194,11 @@ compile_dtl(Config, Source, Target, DtlOpts) -> do_compile(Config, Source, Target, DtlOpts) -> %% TODO: Check last mod on target and referenced DTLs here.. + %% erlydtl >= 0.8.1 does not use the extra indirection using the + %% compiler_options. Kept for backward compatibility with older + %% versions of erlydtl. + CompilerOptions = option(compiler_options, DtlOpts), + %% ensure that doc_root and out_dir are defined, %% using defaults if necessary Opts = lists:ukeymerge(1, @@ -202,7 +207,8 @@ do_compile(Config, Source, Target, DtlOpts) -> [{out_dir, option(out_dir, DtlOpts)}, {doc_root, option(doc_root, DtlOpts)}, {custom_tags_dir, option(custom_tags_dir, DtlOpts)}, - {compiler_options, option(compiler_options, DtlOpts)}])), + {compiler_options, CompilerOptions} + |CompilerOptions])), ?INFO("Compiling \"~s\" -> \"~s\" with options:~n ~s~n", [Source, Target, io_lib:format("~p", [Opts])]), case erlydtl:compile(Source, @@ -220,7 +226,9 @@ do_compile(Config, Source, Target, DtlOpts) -> rebar_base_compiler:error_tuple(Config, Source, [Error], [], Opts); {error, Msg} -> Es = [{Source, [{erlydtl_parser, Msg}]}], - rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts) + rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts); + {error, Es, Ws} -> + rebar_base_compiler:error_tuple(Config, Source, Es, Ws, Opts) end. module_name(Target) -> -- cgit v1.1 From f7d62dee68c7c34866a5b4c5a17078dc4899cc9a Mon Sep 17 00:00:00 2001 From: "David N. Welton" Date: Fri, 14 Feb 2014 11:48:51 +0100 Subject: Use proplists:unfold to make sure we feed a proplist to keymerge. --- src/rebar_erlydtl_compiler.erl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl index ae64bcb..df7186c 100644 --- a/src/rebar_erlydtl_compiler.erl +++ b/src/rebar_erlydtl_compiler.erl @@ -199,16 +199,17 @@ do_compile(Config, Source, Target, DtlOpts) -> %% versions of erlydtl. CompilerOptions = option(compiler_options, DtlOpts), + Sorted = proplists:unfold( + lists:sort( + [{out_dir, option(out_dir, DtlOpts)}, + {doc_root, option(doc_root, DtlOpts)}, + {custom_tags_dir, option(custom_tags_dir, DtlOpts)}, + {compiler_options, CompilerOptions} + |CompilerOptions])), + %% ensure that doc_root and out_dir are defined, %% using defaults if necessary - Opts = lists:ukeymerge(1, - DtlOpts, - lists:sort( - [{out_dir, option(out_dir, DtlOpts)}, - {doc_root, option(doc_root, DtlOpts)}, - {custom_tags_dir, option(custom_tags_dir, DtlOpts)}, - {compiler_options, CompilerOptions} - |CompilerOptions])), + Opts = lists:ukeymerge(1, DtlOpts, Sorted), ?INFO("Compiling \"~s\" -> \"~s\" with options:~n ~s~n", [Source, Target, io_lib:format("~p", [Opts])]), case erlydtl:compile(Source, -- cgit v1.1 From 60d106055b713c939346013edc3dda77469294fe Mon Sep 17 00:00:00 2001 From: "David N. Welton" Date: Fri, 14 Feb 2014 12:30:13 +0100 Subject: {ok, Module} is an acceptable return value from do_compile. --- src/rebar_erlydtl_compiler.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl index df7186c..556e841 100644 --- a/src/rebar_erlydtl_compiler.erl +++ b/src/rebar_erlydtl_compiler.erl @@ -217,6 +217,8 @@ do_compile(Config, Source, Target, DtlOpts) -> Opts) of ok -> ok; + {ok, _Mod} -> + ok; {ok, _Mod, Ws} -> rebar_base_compiler:ok_tuple(Config, Source, Ws); {ok, _Mod, _Bin, Ws} -> -- cgit v1.1