Method: PostHelper#post_summary_html
- Defined in:
- app/helpers/post_helper.rb
#post_summary_html(post) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/post_helper.rb', line 6 def post_summary_html(post) if post.summary.present? content_tag :p, post.summary else html = Sanitizer.new.sanitize(post_content_html(post)) doc = Nokogiri::HTML.fragment(html) para = doc.search('p').detect { |p| p.text.present? } para.try(:to_html).try(:html_safe) end end |