Permalink
Browse files

Permit binaries as proplist keys

git-svn-id: http://erlydtl.googlecode.com/svn/trunk@165 a5195066-8e3e-0410-a82a-05b01b1b9875
  • Loading branch information...
emmiller
emmiller committed Oct 25, 2009
1 parent 20cf7fd commit f0f6ca3b83fe7eb3e41bc689b32ecfacada5fe83
Showing with 11 additions and 1 deletion.
  1. +9 −1 src/erlydtl/erlydtl_runtime.erl
  2. +2 −0 src/tests/erlydtl_unittests.erl
@@ -3,7 +3,15 @@
-compile(export_all).
find_value(Key, L) when is_list(L) ->
- proplists:get_value(Key, L, proplists:get_value(atom_to_list(Key), 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
+ end;
find_value(Key, {GBSize, GBData}) when is_integer(GBSize) ->
case gb_trees:lookup(Key, {GBSize, GBData}) of
{value, Val} ->
@@ -60,6 +60,8 @@ tests() ->
<<"I enjoy {{ var1.game }}">>, [{var1, [{game, "Othello"}]}], <<"I enjoy Othello">>},
{"Render variable with string-key attribute",
<<"I also enjoy {{ var1.game }}">>, [{var1, [{"game", "Parcheesi"}]}], <<"I also enjoy Parcheesi">>},
+ {"Render variable with binary-key attribute",
+ <<"I also enjoy {{ var1.game }}">>, [{var1, [{<<"game">>, "Parcheesi"}]}], <<"I also enjoy Parcheesi">>},
{"Render variable in dict",
<<"{{ var1 }}">>, dict:store(var1, "bar", dict:new()), <<"bar">>},
{"Render variable in gb_tree",

0 comments on commit f0f6ca3

Please sign in to comment.