Permalink
Browse files

support binary templates in compile & render

  • Loading branch information...
1 parent 4514f4f commit 274bd73beeef2a22bd0c21df0a8b5d11ed25d36c @cloudhead committed Jul 19, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/walrus.erl
View
@@ -6,13 +6,17 @@
-define(is_falsy(V),
(V =:= false orelse V =:= [] orelse V =:= undefined orelse V =:= null)).
+compile(Template) when is_binary(Template) ->
+ compile(binary_to_list(Template));
compile(Template) ->
{ok, Tokens, _} = walrus_lexer:string(Template),
{ok, ParseTree} = walrus_parser:parse(Tokens),
fun (Context) ->
render(ParseTree, Context, [])
end.
+render(Template, Context) when is_binary(Template) ->
+ render(binary_to_list(Template), Context);
render(Template, Context) ->
{ok, Tokens, _} = walrus_lexer:string(Template),
{ok, ParseTree} = walrus_parser:parse(Tokens),

0 comments on commit 274bd73

Please sign in to comment.