Просмотр исходного кода

Merge commit 'noss/master' into ejango

Geoff Cant 16 лет назад
Родитель
Сommit
e926041d94

+ 2 - 3
src/erlydtl/erlydtl_compiler.erl

@@ -85,7 +85,6 @@ compile(Binary, Module, Options) when is_binary(Binary) ->
     end;
     
 compile(File, Module, Options) ->  
-    crypto:start(),
     Context = init_dtl_context(File, Module, Options),
     case parse(File, Context) of  
         ok ->
@@ -161,7 +160,7 @@ is_up_to_date(CheckSum, Context) ->
                             ({XFile, XCheckSum}, Acc) ->
                                 case catch M:F(XFile) of
                                     {ok, Data} ->
-                                        case binary_to_list(crypto:sha(Data)) of
+                                        case binary_to_list(erlang:md5(Data)) of
                                             XCheckSum ->
                                                 Acc;
                                             _ ->
@@ -187,7 +186,7 @@ parse(File, Context) ->
     {M, F} = Context#dtl_context.reader,
     case catch M:F(File) of
         {ok, Data} ->
-            CheckSum = binary_to_list(crypto:sha(Data)),
+            CheckSum = binary_to_list(erlang:md5(Data)),
             parse(CheckSum, Data, Context);
         _ ->
             {error, "reading " ++ File ++ " failed "}

+ 4 - 0
src/erlydtl/erlydtl_filters.erl

@@ -188,6 +188,10 @@ urlencode(Input) when is_binary(Input) ->
 urlencode(Input) when is_list(Input) ->
     urlencode(Input, []).
 
+base64(Input) ->
+	base64:encode(erlang:iolist_to_binary(Input)).
+
+
 % internal
 
 escape(Binary, Index) when is_binary(Binary) ->

+ 2 - 0
src/erlydtl/erlydtl_runtime.erl

@@ -2,6 +2,8 @@
 
 -compile(export_all).
 
+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 -> proplists:get_value(atom_to_list(Key), L);

+ 6 - 3
src/erlydtl/erlydtl_scanner.erl

@@ -109,6 +109,9 @@ scan("{%" ++ T, Scanned, {Row, Column}, in_text) ->
 scan([_ | T], Scanned, {Row, Column}, {in_comment, Closer}) ->
     scan(T, Scanned, {Row, Column + 1}, {in_comment, Closer});
 
+%% Drop newlines from lines that end with a backslash
+scan("\\\n" ++ T, Scanned, {Row, _Column}, in_text) ->
+    scan(T, Scanned, {Row + 1, 1}, in_text);
 scan("\n" ++ T, Scanned, {Row, Column}, in_text) ->
     scan(T, append_text_char(Scanned, {Row, Column}, $\n), {Row + 1, 1}, in_text);
 
@@ -194,7 +197,7 @@ scan([H | T], Scanned, {Row, Column}, {in_code, Closer}) ->
         digit ->
             scan(T, [{number_literal, {Row, Column}, [H]} | Scanned], {Row, Column + 1}, {in_number, Closer});
         _ ->
-            {error, io_lib:format("Illegal character line ~p column ~p", [Row, Column])}
+            {error, lists:concat(["Illegal character line ", Row, " column ", Column])}
     end;
 
 scan([H | T], Scanned, {Row, Column}, {in_number, Closer}) ->
@@ -202,7 +205,7 @@ scan([H | T], Scanned, {Row, Column}, {in_number, Closer}) ->
         digit ->
             scan(T, append_char(Scanned, H), {Row, Column + 1}, {in_number, Closer});
         _ ->
-            {error, io_lib:format("Illegal character line ~p column ~p", [Row, Column])}
+            {error, lists:concat(["Illegal character line ", Row, " column ", Column])}
     end;
 
 scan([H | T], Scanned, {Row, Column}, {in_identifier, Closer}) ->
@@ -212,7 +215,7 @@ scan([H | T], Scanned, {Row, Column}, {in_identifier, Closer}) ->
         digit ->
             scan(T, append_char(Scanned, H), {Row, Column + 1}, {in_identifier, Closer});
         _ ->
-            {error, io_lib:format("Illegal character line ~p column ~p", [Row, Column])}
+            {error, lists:concat(["Illegal character line ", Row, " column ", Column])}
     end.
 
 % internal functions