Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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,<<>>}]}
```
  • Loading branch information...
commit a379a0df7793aeb6892945bd964b2f83ff5e4ccf 1 parent 1b59f3c
@kaos kaos authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/erlydtl_filters.erl
View
4 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));
Please sign in to comment.
Something went wrong with that request. Please try again.