Просмотр исходного кода

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 лет назад
Родитель
Сommit
3937d46bda
1 измененных файлов с 3 добавлено и 8 удалено
  1. 3 8
      src/erlydtl_runtime.erl

+ 3 - 8
src/erlydtl_runtime.erl

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