Browse Source

example templates bugfix: call custom tag cannot not call a module which name is a erlydtl tagname, now all examples are building again

Roberto Saccon 17 years ago
parent
commit
dac49f3acf
2 changed files with 22 additions and 16 deletions
  1. 6 6
      examples/docroot/custom_call
  2. 16 10
      src/tests/erlydtl_functional_tests.erl

+ 6 - 6
examples/docroot/custom_call

@@ -1,7 +1,7 @@
->>>> before custom call tag 'test_comment'
-{% call test_comment %}
->>>> after custom call tag 'test_comment'
+>>>> before custom call tag 'comment'
+{% call example_for_preset %}
+>>>> after custom call tag 'comment'
 
->>>> before custom call tag 'test_if'
-{% call test_if with var1 %}
->>>> after custom call tag 'test_if'
+>>>> before custom call tag 'if'
+{% call example_if with var1 %}
+>>>> after custom call tag 'if'

+ 16 - 10
src/tests/erlydtl_functional_tests.erl

@@ -146,7 +146,7 @@ setup("custom_tag") ->
 setup("custom_tag_error") ->
     CompileVars  = [],
     RenderVars = [],
-    {error, CompileVars, ignore, RenderVars};        
+    {error, CompileVars, skip, RenderVars};        
 setup("custom_call") ->
     CompileVars  = [],
     RenderVars = [{var1, "something"}],
@@ -171,8 +171,9 @@ run_tests() ->
                 {N, []}->
                     Msg = lists:concat(["All ", N, " functional tests passed"]),
                     {ok, Msg};
-                {_, Errs} -> 
-                    {error, Errs}
+                {_, Errs} ->
+                    io:format("Errors: ~p~n",[Errs]),
+                    failed
             end;
         Err ->
             Err
@@ -214,24 +215,29 @@ fold_tests() ->
         end, {0, []}). 
 
 
-test_compile_render(File) ->   
-    Module = filename:rootname(filename:basename(File)),
-    case setup(Module) of
+test_compile_render(File) ->  
+    Name = filename:rootname(filename:basename(File)),
+    Module = "example_" ++ Name,
+    case setup(Name) of
         {CompileStatus, CompileVars, RenderStatus, RenderVars} ->
             Options = [
                 {vars, CompileVars}, 
                 {force_recompile, true}],
-            io:format("Template: ~p, ... compiling ... ", [Module]),
+            io:format("Template: ~p, ... compiling ... ", [Name]),
             case erlydtl_compiler:compile(File, Module, Options) of
                 ok ->
                     case CompileStatus of
                         ok -> test_render(File, list_to_atom(Module), RenderStatus, RenderVars);
                         _ -> {error, "compiling should have failed :" ++ File}
                     end;
-                Err ->
+                {error, Err} ->
                     case CompileStatus of
-                        error ->  ok;
-                        _ -> Err
+                        error ->
+                            io:format("~n"),  
+                            ok;
+                        _ ->
+                            io:format("~nCompile errror: ~p~n",[Err]), 
+                            Err
                     end
             end;
         skip ->