Browse Source

Fix broken truncate filters (#138)

```erlang
erlydtl_tests: all_defs_test_ (filters: |truncatewords:0)...*failed*
in function erlydtl_eunit_testrunner:'-run_render/1-fun-0-'/2 (test/erlydtl_eunit_testrunner.erl, line 73)
**error:{assertEqual_failed,[{module,erlydtl_eunit_testrunner},
                     {line,73},
                     {expression,"B"},
                     {expected,<<" ...">>},
                     {value,<<>>}]}
```
Andreas Stenius 11 years ago
parent
commit
a379a0df77
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/erlydtl_filters.erl

+ 2 - 2
src/erlydtl_filters.erl

@@ -821,7 +821,7 @@ truncatechars(Input, Max) ->
     truncatechars_io(cast_to_list(Input), Max, []).
 
 %% @doc Truncates a string after a certain number of words.
-truncatewords(_Input, Max) when Max =< 0 ->
+truncatewords(_Input, Max) when Max < 0 ->
     "";
 truncatewords(Input, Max) when is_binary(Input) ->
     unicode:characters_to_binary(truncatewords(unicode:characters_to_list(Input), Max));
@@ -829,7 +829,7 @@ truncatewords(Input, Max) ->
     truncatewords_io(cast_to_list(Input), Max, []).
 
 %% @doc Similar to truncatewords, except that it is aware of HTML tags.
-truncatewords_html(_Input, Max) when Max =< 0 ->
+truncatewords_html(_Input, Max) when Max < 0 ->
     "";
 truncatewords_html(Input, Max) when is_binary(Input) ->
     unicode:characters_to_binary(truncatewords_html(unicode:characters_to_list(Input), Max));