I think the proper way to do what you want is.... content_tag(:p, truncate("Once upon a time in a world far far away"))
On Thu, Oct 25, 2018 at 7:16 PM arsen oganesian <a.oganes....@gmail.com> wrote: > Hello everybody! > I made a little improvement to ActionView::Helpers::TextHelper#truncate – > added strip_tags: true option, to strip HTML tags in truncated text. > > For example: > truncate("<p>Once upon a time in a world far far away</p>") > # => "<p>Once upon a time in a wo..." > > truncate("<p>Once upon a time in a world far far away</p>", strip_tags: > true) > # => "Once upon a time in a wo..." > > I think this may be useful when truncating rich text, particularly when > there are only annoying opening tags left after truncation. > > Please, let me know what you think about it! Should I open pull request? > I'm new to open source, this may be my first pr ever :) > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at https://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.