Skip to content

Commit

Permalink
Be more Django-y about undefined values
Browse files Browse the repository at this point in the history
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
  • Loading branch information
evanmiller committed Mar 27, 2013
1 parent 4ebc069 commit 3937d46
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/erlydtl_runtime.erl
Expand Up @@ -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) ->
Expand Down

0 comments on commit 3937d46

Please sign in to comment.