Sha256: 3c5e6ee67106393f54c6b3601c0f05f99ae26c092a3c293aaf1372f3502449f2

Contents?: true

Size: 1.38 KB

Versions: 21

Compression:

Stored size: 1.38 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_with_processor(:hashtag, 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

21 entries across 21 versions & 1 rubygems

Version Path
decidim-proposals-0.23.6 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.5 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.4 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.3 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.1.rc1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.23.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.22.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.21.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.20.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.20.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.19.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.18.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.19.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.17.2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.18.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.17.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.16.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.17.0 app/commands/decidim/proposals/hashtags_methods.rb