Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #26 from fauxsoup/master

Use lists module for erlydtl_runtime:find_value
  • Loading branch information...
commit 2c62bd083f12bbee7b74e7f7169f28cd2b4cc32e 2 parents caa53a0 + 3b119a9
@evanmiller evanmiller authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/erlydtl_runtime.erl
View
23 src/erlydtl_runtime.erl
@@ -8,15 +8,20 @@ find_value(_, undefined) ->
undefined;
find_value(Key, Fun) when is_function(Fun, 1) ->
Fun(Key);
-find_value(Key, L) when is_list(L) ->
- case proplists:get_value(Key, L) of
- undefined ->
- case proplists:get_value(atom_to_list(Key), L) of
- undefined ->
- proplists:get_value(list_to_binary(atom_to_list(Key)), L);
- Val -> Val
- end;
- Val -> Val
+find_value(Key, L) when is_atom(Key), is_list(L) ->
+ case lists:keyfind(Key, 1, L) of
+ false -> find_value(atom_to_list(Key), L);
+ {Key, Value} -> Value
+ end;
+find_value(Key, L) when is_list(Key), is_list(L) ->
+ case lists:keyfind(Key, 1, L) of
+ false -> find_value(list_to_binary(Key), L);
+ {Key, Value} -> Value
+ end;
+find_value(Key, L) when is_binary(Key), is_list(L) ->
+ case lists:keyfind(Key, 1, L) of
+ false -> undefined;
+ {Key, Value} -> Value
end;
find_value(Key, {GBSize, GBData}) when is_integer(GBSize) ->
case gb_trees:lookup(Key, {GBSize, GBData}) of
Please sign in to comment.
Something went wrong with that request. Please try again.