Method: EffectivePostsHelper#post_excerpt
- Defined in:
- app/helpers/effective_posts_helper.rb
#post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length: 200) ⇒ Object
Only supported options are: :label => ‘Read more’ to set the label of the ‘Read More’ link :omission => ‘…’ passed to the final text node’s truncate :length => 200 to set the max inner_text length of the content All other options are passed to the link_to ‘Read more’
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/helpers/effective_posts_helper.rb', line 71 def post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length: 200) content = effective_region(post, :body, :editable => false) { '<p>Default content</p>'.html_safe } description = content_tag(:p, post.description) divider = content.index(Effective::Snippets::ReadMoreDivider::TOKEN) read_more = (read_more_link && label.present?) ? readmore_link(post, label: label) : '' CGI.unescapeHTML(if divider.present? truncate_html(content, Effective::Snippets::ReadMoreDivider::TOKEN, '') + read_more elsif length.present? truncate_html(description, length, omission) + read_more else description end).html_safe end |