Answer the question
In order to leave comments, you need to log in
Why does the truncate helper output html tags?
1. article.body = article text
Why does truncate print html tags to the screen? Can anyone use similar helpers that do the job?
<p><%= truncate simple_format article.body, length: 200 %></p>
Answer the question
In order to leave comments, you need to log in
Have you tried looking
at the documentation ?
The result is marked as HTML-safe, but it is escaped by default, unless :escape is false. Care should be taken if text contains HTML tags or entities, because truncation may produce invalid HTML (such as unbalanced or incomplete tags).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question