Sha256: afd994605f252b05decd91e1aec39521ad0206f2752d7aa34d7fe219627a8ce5

Contents?: true

Size: 632 Bytes

Versions: 13

Compression:

Stored size: 632 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Blogs
    # Custom helpers used in posts views
    module PostsHelper
      include Decidim::ApplicationHelper
      include Decidim::TranslationsHelper
      include Decidim::ResourceHelper

      # Public: truncates the post body
      #
      # post - a Decidim::Blog instance
      # max_length - a number to limit the length of the body
      #
      # Returns the post's body truncated.
      def post_description(post, max_length = 300)
        body = translated_attribute(post.body)
        CGI.unescapeHTML html_truncate(body, max_length:)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-blogs-0.29.1 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.4 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.29.0 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.3 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.29.0.rc4 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.29.0.rc3 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.29.0.rc2 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.29.0.rc1 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.2 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.1 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.0 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.0.rc5 app/helpers/decidim/blogs/posts_helper.rb
decidim-blogs-0.28.0.rc4 app/helpers/decidim/blogs/posts_helper.rb