Module: Decidim::IconHelper
- Defined in:
- app/helpers/decidim/icon_helper.rb
Overview
Helpers related to icons
Instance Method Summary collapse
-
#feature_icon(feature, options = {}) ⇒ Object
Public: Returns an icon given an instance of a Feature.
-
#manifest_icon(manifest, options = {}) ⇒ Object
Public: Returns an icon given an instance of a Manifest.
-
#resource_icon(resource, options = {}) ⇒ Object
Public: Finds the correct icon for the given resource.
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 'app/helpers/decidim/icon_helper.rb', line 13 def feature_icon(feature, = {}) manifest_icon(feature.manifest, ) 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 'app/helpers/decidim/icon_helper.rb', line 24 def manifest_icon(manifest, = {}) if manifest.icon external_icon manifest.icon, else icon "question-mark", 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 'app/helpers/decidim/icon_helper.rb', line 40 def resource_icon(resource, = {}) if resource.respond_to?(:feature) feature_icon(resource.feature, ) else manifest_icon(resource.manifest, ) end end |