Browse Source

fixed tests for htmltags and csstags

Roberto Saccon 17 years ago
parent
commit
add3f246af
4 changed files with 35 additions and 22 deletions
  1. 0 1
      demo/out/test_csstags.css
  2. 3 4
      demo/out/test_htmltags.html
  3. 27 7
      src/demo/erlydtl_demo.erl
  4. 5 10
      src/erlydtl/erlydtl_server.erl

+ 0 - 1
demo/out/test_csstags.css

@@ -2,7 +2,6 @@
     width: 10px;
 }
 
-
  /*================= STYLES FOR THE GRC MASTHEAD & CONTROLS ==================*/
 
 .menuminwidth0 {             /* for all browsers (non-IE) that obey min-width */

+ 3 - 4
demo/out/test_htmltags.html

@@ -6,17 +6,16 @@
   </head>
   <body>
 	before
-	
-<object id="myvideo" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="600">
+	<object id="myvideo" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="600">
 	<param name="movie" value="/static/mediaplayer.swf">
     <param name="allowfullscreen" value="true">
     <param name="menu" value="false">
-    <param name="flashvars" value="file=/static/myvideo.mp4&image=/static/mypreview.jpg">
+    <param name="flashvars" value="file=/myvid.mp4&image=/mypic.jpg">
     <!--[if !IE]>-->
     <object type="application/x-shockwave-flash" data="/static/mediaplayer.swf" width="800" height="620">
     <param name="allowfullscreen" value="true">
     <param name="menu" value="false">
-    <param name="flashvars" value="file=/static/myvideo.mp4&image=/static/mypreview.jpg">
+    <param name="flashvars" value="file=/myvid.mp4&image=/mypic.jpg">
     <!--<![endif]-->
     <h2>To view the Video:</h2>
     <p>

+ 27 - 7
src/demo/erlydtl_demo.erl

@@ -62,10 +62,28 @@ compile() ->
 %% compiles the template to beam files
 %% @end 
 %%--------------------------------------------------------------------        
-compile(Name) ->
-     compile(Name, ".html").
-      
+compile("var" = Name) ->
+    compile(Name, ".html");
+
+compile("extends" = Name) ->
+    compile(Name, ".html"); 
+          
+compile("comment" = Name) ->
+    compile(Name, ".html");
+               
+compile("for" = Name) ->
+    compile(Name, ".css");
+                        
+compile("htmltags" = Name) ->
+    compile(Name, ".html");
+                    
+compile("csstags" = Name) ->
+     compile(Name, ".css");
       
+compile(Name) ->
+    io:format("No such template: ~p~n",[Name]).
+               
+               
 %%--------------------------------------------------------------------
 %% @spec (string(), string()) -> any()
 %% @doc 
@@ -114,10 +132,12 @@ render("htmltags" = Name) ->
     render(Name, ".html");
     
 render("csstags" = Name) ->
-    render(Name, ".html").    
-                    
-
-
+    render(Name, ".css");
+    
+render(Name) ->
+    io:format("No such template: ~p~n",[Name]).  
+                
+                
 %%--------------------------------------------------------------------
 %% @spec (atom(), string()) -> any()
 %% @doc renders template to a file

+ 5 - 10
src/erlydtl/erlydtl_server.erl

@@ -329,9 +329,9 @@ parse_transform({var, Line, Val}, Var, Val) when is_atom(Var) ->
     {var, Line, Var}.
     
             
-parse_transform({var, Line, Val}, Args) ->
-    {value, {_, Value}} = lists:keysearch(Val, 1, Args),
-    binary_string(Value);      
+parse_transform({var, _Line, Var}, Args) ->
+    Var2 = list_to_atom(tl(atom_to_list(Var))),
+    binary_string(proplists:get_value(Var2, Args));      
 parse_transform(Other, _) ->    
     Other.
         
@@ -347,21 +347,16 @@ parse_transform(Other) ->
 
    	        	
 load_tag(TagName, TagArgs, Acc0, default, Ext, IgnoreVar) ->
-io:format("TRACE ~p:~p TagArgs ~p~n",[?MODULE, ?LINE, TagArgs]),
     case parse(filename:join([erlydtl_deps:get_base_dir(), "priv", "tags", atom_to_list(TagName) ++ Ext])) of
         {ok, ParentAst} ->
 		    [H|T]=ParentAst,
-			{_, List, Args1} = build_tree(H, T, [], [], undefined, Ext, IgnoreVar),
-io:format("TRACE ~p:~p Args1 ~p~n",[?MODULE, ?LINE, Args1]),
-			Args2 = [{Var, Val} || {{Var, _}, Val} <- lists:zip(Args1, TagArgs)], 	
-io:format("TRACE ~p:~p Args2 ~p~n",[?MODULE, ?LINE, Args2]),		
+			{_, List, _} = build_tree(H, T, [], [], undefined, Ext, IgnoreVar),			
 			lists:foldl(fun(X, Acc) -> 
-			        [parse_transform(X, Args2) | Acc]			        
+			        [parse_transform(X, TagArgs) | Acc]			        
 			    end, 
 			    Acc0,
 			    lists:reverse(List));
 		{error, Msg} ->
-    	    io:format("TRACE ~p:~p ~p~n",[?MODULE, ?LINE, Msg]),
     	    Acc0
     end.