Sha256: ef39261f3d472d14e019253573e70f91d9f26f7a06e5ec4cafb3866be6823783

Contents?: true

Size: 1.03 KB

Versions: 25

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    # A helper to expose the comments component for a commentable
    module CommentsHelper
      # Render commentable comments inside the `expanded` template content.
      #
      # resource - A commentable resource
      def comments_for(resource, options = {})
        return unless resource.commentable?

        content_for :expanded do
          inline_comments_for(resource, options)
        end
      end

      # Creates a Comments component through the comments cell.
      #
      # resource - A commentable resource
      #
      # Returns the comments cell
      def inline_comments_for(resource, options = {})
        return unless resource.commentable?

        cell(
          "decidim/comments/comments",
          resource,
          machine_translations: machine_translations_toggled?,
          single_comment: params.fetch("commentId", nil),
          order: options[:order],
          polymorphic: options[:polymorphic]
        ).to_s
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-comments-0.27.9 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.8 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.7 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.6 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.10 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.9 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.5 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.8 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.4 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.3 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.7 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.5 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.2 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.1 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.4 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.0 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.3 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.0.rc2 lib/decidim/comments/comments_helper.rb
decidim-comments-0.27.0.rc1 lib/decidim/comments/comments_helper.rb
decidim-comments-0.26.2 lib/decidim/comments/comments_helper.rb