Sha256: 43a35778cb956474ce8beb43caab09112e7df4d614a878eaa37cd80219a995e2

Contents?: true

Size: 788 Bytes

Versions: 51

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Helper to print resource references.
  module ResourceReferenceHelper
    # Displays the localized reference for the given resource.
    #
    # resource - the Resource that has the reference to display.
    # options - An optional hash of options
    #         * class: A string of extra css classes
    #
    # Returns a String.
    def resource_reference(resource, options = {})
      return unless resource.respond_to?(:reference) && resource.reference.present?

      "<div class='tech-info #{options[:class]}'>#{localized_reference(resource.reference)}</div>".html_safe
    end

    private

    def localized_reference(reference)
      I18n.t("reference", reference: reference, scope: "decidim.shared.reference")
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

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