Is there an HTML safe truncate method in Rails?

后端 未结 10 689
执笔经年
执笔经年 2020-12-24 05:45

I have a string of HTML in Rails. I\'d like to truncate the string after a certain number of characters not including the HTML markup. Also, if the split happens to fall in

10条回答
  •  情书的邮戳
    2020-12-24 05:50

    You could use the truncate_html plugin for this. It uses nokogiri and htmlentities gems and does exactly what the plugin name suggests.

提交回复
热议问题