evanmiller/erlydtl — pull request #43 by saleyn (2012-10-18 00:48:16+00:00)
Title: Handle compiler return code, and emit good code for erl_prettypr decompilation.

Bug fixes:
1. When compiler_option includes 'return', properly handle Error and Warnings
returned by the compiler, so that the user still gets 'ok' instead of
{ok, Module, Bin, {Errors, Warnings}}, which rebar doesn't property handle.

2. When compiling templates with custom tags with a given custom_tags_modules
option, the arguments were saved as atoms in the AST as opposed to strings.
This caused a failure when decompiling the beam and printing its source
by erl_prettypr.

3. Local unused function render_tags/3 emitted in templates was compiling with
a warning. Made it exported to suppress the warnings.

In order to illustrate the issue compile the template test.dtl containing:

{% tr xxx="ABC" %}

with options:

[
, {doc_root, "src"}
, {out_dir, "ebin"}
, {compiler_options, [verbose, debug_info, report, return]}
, {custom_tags_modules, [custom_tags]}
, {force_recompile, true}
].

where custom_tags module is:

-module(custom_tags).

-export([tr/2]).

tr(Vars, Context) ->
io:format("Vars: ~p\n Context: ~p\n", [Vars, Context]),
[].

Observe the return code of erlydtl_compiler:compile/3, and also try to
decompile the emitted beam with:
[http://erlang.org/pipermail/erlang-questions/2006-January/018813.html]