Sha256: a6db859119ca11b7338989125440951f3f927325df321bcd3ea48077ce858a6a

Contents?: true

Size: 1.38 KB

Versions: 17

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

17 entries across 17 versions & 1 rubygems

Version Path
decidim-proposals-0.26.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.0.rc2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.26.0.rc1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.0.rc4 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.0.rc3 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.0.rc2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.25.0.rc1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.3 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.1 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.0 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.0.rc2 app/commands/decidim/proposals/hashtags_methods.rb
decidim-proposals-0.24.0.rc1 app/commands/decidim/proposals/hashtags_methods.rb