Browse Source

Be more Django-y about undefined values

Previously evaluating undefined variables threw an error. Django
doesn't do this, so we won't either. Instead evaluate to the empty
list, which conveniently enough works both as an emptry string
and as an empty array
Evan Miller 12 years ago
parent
commit
3937d46bda
1 changed files with 3 additions and 8 deletions
  1. 3 8
      src/erlydtl_runtime.erl

+ 3 - 8
src/erlydtl_runtime.erl

@@ -59,15 +59,10 @@ find_deep_value([Key|Rest],Item) ->
     end;
     end;
 find_deep_value([],Item) -> Item.
 find_deep_value([],Item) -> Item.
 
 
-fetch_value(Key, Data, FileName, Pos) ->
+fetch_value(Key, Data, _FileName, _Pos) ->
     case find_value(Key, Data) of
     case find_value(Key, Data) of
-        undefined ->
-            throw({undefined_variable, 
-                    [{name, Key},
-                        {file, FileName},
-                        {line, Pos}]});
-        Val ->
-            Val
+        undefined -> [];
+        Val -> Val
     end.
     end.
 
 
 regroup(List, Attribute) ->
 regroup(List, Attribute) ->