Commits

Anonymous committed 550ca5d

Do not require a space between a variable name and closing bracket, e.g. allow "{{var1}}"

Comments (0)

Files changed (2)

src/erlydtl/erlydtl_scanner.erl

 scan(" " ++ T, Scanned, {Row, Column}, {_, Closer}) ->
     scan(T, Scanned, {Row, Column + 1}, {in_code, Closer});
 
-scan("}}-->" ++ T, Scanned, {Row, Column}, {in_code, "}}-->"}) ->
+scan("}}-->" ++ T, Scanned, {Row, Column}, {_, "}}-->"}) ->
     scan(T, [{close_var, {Row, Column}, lists:reverse("}}-->")} | Scanned], 
         {Row, Column + 2}, in_text);
 
-scan("}}" ++ T, Scanned, {Row, Column}, {in_code, "}}"}) ->
+scan("}}" ++ T, Scanned, {Row, Column}, {_, "}}"}) ->
     scan(T, [{close_var, {Row, Column}, "}}"} | Scanned], {Row, Column + 2}, in_text);
 
-scan("%}-->" ++ T, Scanned, {Row, Column}, {in_code, "%}-->"}) ->
+scan("%}-->" ++ T, Scanned, {Row, Column}, {_, "%}-->"}) ->
     scan(T, [{close_tag, {Row, Column}, lists:reverse("%}-->")} | Scanned], 
         {Row, Column + 2}, in_text);
 
-scan("%}" ++ T, Scanned, {Row, Column}, {in_code, "%}"}) ->
+scan("%}" ++ T, Scanned, {Row, Column}, {_, "%}"}) ->
     scan(T, [{close_tag, {Row, Column}, lists:reverse("%}")} | Scanned], 
         {Row, Column + 2}, in_text);
 

src/tests/erlydtl_unittests.erl

                     [{var1, 42}], <<"The magic number is: 42">>},
                 {"float",
                     <<"The price of milk is: {{ var1 }}">>,
-                    [{var1, 0.42}], <<"The price of milk is: 0.42">>}
+                    [{var1, 0.42}], <<"The price of milk is: 0.42">>},
+                {"No spaces",
+                    <<"{{var1}}">>,
+                    [{var1, "foo"}], <<"foo">>}
             ]},
         {"comment", [
                 {"comment block is excised",