A
A
anasasiakiri4enko2016-06-17 15:30:38
Ruby on Rails
anasasiakiri4enko, 2016-06-17 15:30:38

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

1 answer(s)
A
Andrey Demidenko, 2016-06-17
@anasasiakiri4enko

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 question

Ask a Question

731 491 924 answers to any question