Commits

Anonymous committed 0807df4

* If variable is a function with 0 args, evaluate it.

Thanks to rumata-e...@nm.ru.

  • Participants
  • Parent commits c2adb41

Comments (0)

Files changed (2)

File src/erlydtl/erlydtl_filters.erl

     integer_to_list(Input);
 format_number(Input) when is_float(Input) ->
     io_lib:format("~p", [Input]);
+format_number(Input) when is_function(Input, 0) ->
+    format_number(Input());
 format_number(Input) ->
     Input.
 

File src/tests/erlydtl_unittests.erl

                     <<"{{ var1|format_number }}">>, [{var1, "28.77"}], <<"28.77">>},
                 {"|format_number 4",
                     <<"{{ var1|format_number }}">>, [{var1, "23.77"}], <<"23.77">>},
+                {"|format_number 5",
+                    <<"{{ var1|format_number }}">>, [{var1, fun() -> 29 end}], <<"29">>},
+                {"|format_number 6",
+                    <<"{{ var1|format_number }}">>, [{var1, fun() -> fun() -> 31 end end}], <<"31">>},
  
                 {"|join:\", \"",
                     <<"{{ var1|join:\", \" }}">>, [{var1, ["Liberte", "Egalite", "Fraternite"]}],