Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* Change: No .beam file will be generated unless out_dir is specified.

* Document out_dir in README
* If there is a compilation error, print name of offending file.

Thanks to Liu Yubao for the patches.



git-svn-id: http://erlydtl.googlecode.com/svn/trunk@149 a5195066-8e3e-0410-a82a-05b01b1b9875
  • Loading branch information...
commit bd26c620c0b6c30fd5b5420517eb53f13c45eaee 1 parent bb48da2
emmiller authored

Showing 2 changed files with 19 additions and 7 deletions. Show diff stats Hide diff stats

  1. +3 0  README
  2. +16 7 src/erlydtl/erlydtl_compiler.erl
3  README
@@ -27,6 +27,9 @@ Four ways:
27 27
28 28 Options is a proplist possibly containing:
29 29
  30 + out_dir - Directory to store generated .beam files. If not specified, no
  31 + .beam files will be created.
  32 +
30 33 doc_root - Included template paths will be relative to this directory;
31 34 defaults to the compiled template's directory.
32 35
23 src/erlydtl/erlydtl_compiler.erl
@@ -93,13 +93,17 @@ compile(File, Module, Options) ->
93 93 {ok, DjangoParseTree, CheckSum} ->
94 94 case compile_to_binary(File, DjangoParseTree, Context, CheckSum) of
95 95 {ok, Module1, Bin} ->
96   - OutDir = proplists:get_value(out_dir, Options, "ebin"),
97   - BeamFile = filename:join([OutDir, atom_to_list(Module1) ++ ".beam"]),
98   - case file:write_file(BeamFile, Bin) of
99   - ok ->
  96 + case proplists:get_value(out_dir, Options) of
  97 + undefined ->
100 98 ok;
101   - {error, Reason} ->
102   - {error, lists:concat(["beam generation failed (", Reason, "): ", BeamFile])}
  99 + OutDir ->
  100 + BeamFile = filename:join([OutDir, atom_to_list(Module1) ++ ".beam"]),
  101 + case file:write_file(BeamFile, Bin) of
  102 + ok ->
  103 + ok;
  104 + {error, Reason} ->
  105 + {error, lists:concat(["beam generation failed (", Reason, "): ", BeamFile])}
  106 + end
103 107 end;
104 108 Err ->
105 109 Err
@@ -188,7 +192,12 @@ parse(File, Context) ->
188 192 case catch M:F(File) of
189 193 {ok, Data} ->
190 194 CheckSum = binary_to_list(crypto:sha(Data)),
191   - parse(CheckSum, Data, Context);
  195 + case parse(CheckSum, Data, Context) of
  196 + {error, Msg} when is_list(Msg) ->
  197 + {error, File ++ ": " ++ Msg};
  198 + Result ->
  199 + Result
  200 + end;
192 201 _ ->
193 202 {error, "reading " ++ File ++ " failed "}
194 203 end.

0 comments on commit bd26c62

Please sign in to comment.
Something went wrong with that request. Please try again.