Erlydtl compiler #44

merged 2 commits into from Oct 26, 2012


None yet
2 participants

saleyn commented Oct 19, 2012

Three bug fixes described in individual commits


saleyn commented Oct 25, 2012

Also I removed the commit that exported render_tag/3.

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

* Add `verbose` compiler option.

saleyn commented Oct 26, 2012

Please see the changes in both commits that address your concerns. Promoted verbose to be 1st class ErlyDTL option, fixed the compiler to save custom tags argument key as atom as opposed to be a string.


evanmiller commented Oct 26, 2012

Hmm. Don't you just want

erl_syntax:string(atom_to_list(Key)) ?

So the semantics of the BEAM are unchanged.


saleyn commented Oct 26, 2012

I was unsure as to what you had in mind when you wrote in the implementation erl_syntax:string(Atom). Was it that you wanted the result to be represented as an atom or a string? With that the beam compiled fine, and I am unsure what the impact of that implementation would be at run-time. But an attempt to decompile the beam into the source code failed miserably, so I wanted to fix that. Just let me know if you want the named arguments to be stored as atoms or strings, and I'll patch it accordingly. For my own purpose it doesn't make a difference, so the decision is yours.


evanmiller commented Oct 26, 2012

Please store them as strings as they are stored now.

Bug fix in saving template containing custom_tags_modules feature
* Bug fix: when compiling templates with custom tags with a given
custom_tags_modules option, the arguments are saved as atoms in the
AST as opposed to strings. This causes a failure when decompiling
the beam and printing its source by erl_prettypr.

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:



    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:

saleyn commented Oct 26, 2012

Ok, this last commit does it the way you recommended.


evanmiller commented Oct 26, 2012


evanmiller added a commit that referenced this pull request Oct 26, 2012

@evanmiller evanmiller merged commit 2ef2f7d into erlydtl:master Oct 26, 2012


saleyn commented Oct 26, 2012

Great! Thanks for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment