Browse Source

add debug_compiler to the list of valid compiler options.

This will dump the compiled template module source to stdout.
Andreas Stenius 12 years ago
parent
commit
9f124f446f
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/erlydtl_compiler.erl

+ 6 - 0
src/erlydtl_compiler.erl

@@ -219,6 +219,12 @@ compile_to_binary(File, DjangoParseTree, Context, CheckSum) ->
     end.
     end.
 
 
 compile_forms_and_reload(File, Forms, CompilerOptions) ->
 compile_forms_and_reload(File, Forms, CompilerOptions) ->
+    case proplists:get_value(debug_compiler, CompilerOptions) of
+	true ->
+	    io:format("Template ~p compiled with options: ~p~n", [File, CompilerOptions]),
+	    [io:format("~s~n", [erl_pp:form(Form)]) || Form <- Forms];
+	_ -> nop
+    end,
     case compile:forms(Forms, CompilerOptions) of
     case compile:forms(Forms, CompilerOptions) of
         {ok, Module1, Bin} -> 
         {ok, Module1, Bin} -> 
             load_code(Module1, Bin, []);
             load_code(Module1, Bin, []);