PATCH: Incorrect handling of if without else

3 views
Skip to first unread message

Hunter Morris

unread,
Mar 28, 2008, 4:25:42 PM3/28/08
to sgte - A simple Erlang Template Engine
I found a bug where:

$if foo.bar$
foo
$end if$

is parsed differently than:

$if foo.bar$
foo
$else$
bar
$end if$

I've included a patch that should fix the issue:

===================================================================
--- sgte_parse.erl (revision 139)
+++ sgte_parse.erl (working copy)
@@ -338,7 +338,9 @@
case parse(Then) of
{error, Reason} -> {error, Reason};
{ok, CThen} ->
- {ift, {{attribute, list_to_atom(string:strip(Test))}, CThen}}
+ TestTok = [list_to_atom(T) ||
+ T <- string:tokens(string:strip(Test),
".")],
+ {ift, {{attribute, TestTok}, CThen}}
end.

%
%--------------------------------------------------------------------

Filippo Pacini

unread,
Mar 29, 2008, 6:33:10 AM3/29/08
to Hunter Morris, sgte - A simple Erlang Template Engine
Thanks Hunter,
patch applied.

cheers,
filippo

Reply all
Reply to author
Forward
0 new messages