Sha256: 8373f21d0e6f97a903ae1ec2b7f3278f1b20f7321c5c00e07618c9181abc0f5b

Contents?: true

Size: 1023 Bytes

Versions: 4

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Helpers related to the Participatory Process layout.
  module ParticipatoryProcessHelper
    # Public: Returns the dates for a step in a readable format like
    # "2016-01-01 - 2016-02-05".
    #
    # participatory_process_step - The step to format to
    #
    # Returns a String with the formatted dates.
    def participatory_process_step_dates(participatory_process_step)
      dates = [participatory_process_step.start_date, participatory_process_step.end_date]
      dates.map { |date| date ? localize(date.to_date, format: :default) : "?" }.join(" - ")
    end

    # Public: Returns an icon given an instance of a Feature. It defaults to
    # a question mark when no icon is found.
    #
    # feature - The feature to generate the icon for.
    #
    # Returns an HTML tag with the icon.
    def feature_icon(feature)
      if feature.manifest.icon
        external_icon feature.manifest.icon
      else
        icon "question-mark"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.3.2 app/helpers/decidim/participatory_process_helper.rb
decidim-core-0.3.1 app/helpers/decidim/participatory_process_helper.rb
decidim-core-0.3.0 app/helpers/decidim/participatory_process_helper.rb
decidim-core-0.2.0 app/helpers/decidim/participatory_process_helper.rb