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

Merge pull request #208 from pablo-meier/truncatewords_html_bugfix

Fix bug in truncatewords_html on closing tags
Andreas Stenius 10 лет назад
Родитель
Сommit
0c1dd00ca1
2 измененных файлов с 6 добавлено и 1 удалено
  1. 3 1
      src/erlydtl_filters.erl
  2. 3 0
      test/erlydtl_test_defs.erl

+ 3 - 1
src/erlydtl_filters.erl

@@ -1117,7 +1117,9 @@ truncatewords_html_io([C|Rest], WordsLeft, Acc, Tags, tag) ->
 truncatewords_html_io([C|Rest], WordsLeft, Acc, Tags, attrs) when C =:= $> ->
     truncatewords_html_io(Rest, WordsLeft, [C|Acc], Tags, text);
 truncatewords_html_io([C|Rest], WordsLeft, Acc, [_Tag|RestOfTags], close_tag) when C =:= $> ->
-    truncatewords_html_io(Rest, WordsLeft, [C|Acc], RestOfTags, text).
+    truncatewords_html_io(Rest, WordsLeft, [C|Acc], RestOfTags, text);
+truncatewords_html_io([C|Rest], WordsLeft, Acc, Tags, close_tag) when C =/= $> ->
+    truncatewords_html_io(Rest, WordsLeft, [C|Acc], Tags, close_tag).
 
 wordcount([], Count) ->
     Count;

+ 3 - 0
test/erlydtl_test_defs.erl

@@ -1059,6 +1059,9 @@ all_test_defs() ->
        {"|truncatewords_html:4",
         <<"{{ var1|truncatewords_html:4 }}">>, [{var1, "<p>The <strong>Long and <em>Winding</em> Road</strong> is too long</p>"}],
         <<"<p>The <strong>Long and <em>Winding</em>...</strong></p>">>},
+       {"|truncatewords_html:50",
+        <<"{{ var1|truncatewords_html:50 }}">>, [{var1, "<p>The <strong>Long and <em>Winding</em> Road</strong> is too long</p>"}],
+        <<"<p>The <strong>Long and <em>Winding</em> Road</strong> is too long</p>">>},
        {"|unordered_list",
         <<"{{ var1|unordered_list }}">>, [{var1, ["States", ["Kansas", ["Lawrence", "Topeka"], "Illinois"]]}],
         <<"<li>States<ul><li>Kansas<ul><li>Lawrence</li><li>Topeka</li></ul></li><li>Illinois</li></ul></li>">>},