Sha256: 3fce6268750508a6c2b031c558e6a4f0b2e9e5391139ca33ed3b0373fe57be02

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    # A module with all the hash tags common methods for proposals
    # and collaborative draft commands.
    module HashtagsMethods
      private

      def title_with_hashtags
        @title_with_hashtags ||= Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
      end

      def body_with_hashtags
        @body_with_hashtags ||= begin
          ret = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite.strip
          ret += "\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
          ret
        end
      end

      def body_extra_hashtags
        @body_extra_hashtags ||= if form.respond_to?(:extra_hashtags)
                                   Decidim::ContentProcessor.parse_with_processor(
                                     :hashtag,
                                     form.extra_hashtags.map { |hashtag| "##{hashtag}" }.join(" "),
                                     current_organization: form.current_organization,
                                     extra_hashtags: true
                                   ).rewrite
                                 else
                                   ""
                                 end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-proposals-0.27.9 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.8 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.7 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.6 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.10 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.9 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.5 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.8 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.4 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.3 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.7 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.5 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.4 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.3 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.0.rc2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.27.0.rc1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.2 app/commands/decidim/proposals/hashtags_methods.rb