Method: EffectivePostsHelper#post_excerpt
- Defined in:
- app/helpers/effective_posts_helper.rb
#post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length: nil) ⇒ 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’
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/helpers/effective_posts_helper.rb', line 80 def post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length: nil) content = effective_region(post, :body, editable: false) { '<p>Default content</p>'.html_safe } divider = content.index(Effective::Snippets::ReadMoreDivider::TOKEN) excerpt = post.excerpt.to_s read_more = (read_more_link && label.present?) ? readmore_link(post, label: label) : '' html = ( if divider.present? truncate_html(content, Effective::Snippets::ReadMoreDivider::TOKEN, '') elsif length.present? truncate_html(excerpt, length, omission) else excerpt end ).html_safe (html + read_more).html_safe end |