Module: Decidim::IconHelper

Included in:
Assemblies::AssemblyStatsPresenter, ParticipatoryProcesses::ParticipatoryProcessStatsPresenter
Defined in:
decidim-core/app/helpers/decidim/icon_helper.rb

Overview

Helpers related to icons

Instance Method Summary collapse

Instance Method Details

#feature_icon(feature, options = {}) ⇒ Object

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. options - a Hash with options

Returns an HTML tag with the icon.



13
14
15
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 13

def feature_icon(feature, options = {})
  manifest_icon(feature.manifest, options)
end

#manifest_icon(manifest, options = {}) ⇒ Object

Public: Returns an icon given an instance of a Manifest. It defaults to a question mark when no icon is found.

manifest - The manifest to generate the icon for. options - a Hash with options

Returns an HTML tag with the icon.



24
25
26
27
28
29
30
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 24

def manifest_icon(manifest, options = {})
  if manifest.icon
    external_icon manifest.icon, options
  else
    icon "question-mark", options
  end
end

#resource_icon(resource, options = {}) ⇒ Object

Public: Finds the correct icon for the given resource. If the resource has a Feature then it uses it to find the icon, otherwise checks for the resource manifest to find the icon.

resource - The resource to generate the icon for. options - a Hash with options

Returns an HTML tag with the icon.



40
41
42
43
44
45
46
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 40

def resource_icon(resource, options = {})
  if resource.respond_to?(:feature)
    feature_icon(resource.feature, options)
  else
    manifest_icon(resource.manifest, options)
  end
end