Module: SpudBannersHelper
- Included in:
- Spud::Banners::BannerSetTag
- Defined in:
- app/helpers/spud_banners_helper.rb
Instance Method Summary collapse
-
#spud_banner_image_tag(banner) ⇒ Object
Returns an HTML <img/> tag for a single banner.
-
#spud_banner_tag(banner, options = {}) ⇒ Object
Returns an HTML tag for a single banner May return either an <img/> or an <a/> depending on the banner.
-
#spud_banners_for_set(set_or_identifier, options = {}) ⇒ Object
Returns banner html for a given identifier Generated HTML will be cached if your application uses fragment caching.
-
#spud_banners_set_tag(banner_set, options = {}) ⇒ Object
Returns banner html for a given banner_set.
Instance Method Details
#spud_banner_image_tag(banner) ⇒ Object
Returns an HTML <img/> tag for a single banner
70 71 72 |
# File 'app/helpers/spud_banners_helper.rb', line 70 def () image_tag(..url(:banner), :alt => .alt, :title => .title) end |
#spud_banner_tag(banner, options = {}) ⇒ Object
Returns an HTML tag for a single banner May return either an <img/> or an <a/> depending on the banner
58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/spud_banners_helper.rb', line 58 def (, ={}) if .link_to.blank? () else link_to(.link_to, :target => .link_target) do () end end end |
#spud_banners_for_set(set_or_identifier, options = {}) ⇒ Object
Returns banner html for a given identifier Generated HTML will be cached if your application uses fragment caching
-
set_or_identifier: A reference to a SpudBannerSet, or the name of a known banner set passed as a symbol (ie, :home)
-
options:
-
limit: Max number of banners to return
-
background_image: Pass true to return the banners as CSS background-image properties rather than <img/> tags
-
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/spud_banners_helper.rb', line 11 def (set_or_identifier, = {}) if set_or_identifier.is_a?(SpudBannerSet) = set_or_identifier else = SpudBannerSet.find_by_identifier(set_or_identifier) end return '' if .blank? cache() do concat (, ) end end |
#spud_banners_set_tag(banner_set, options = {}) ⇒ Object
Returns banner html for a given banner_set
-
banner_set: A reference to a SpudBannerSet
-
options:
-
limit: Max number of banners to return
-
background_image: Pass true to return the banners as CSS background-image properties rather than <img/> tags
-
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/helpers/spud_banners_helper.rb', line 30 def (, = {}) background_image = .delete(:background_image) limit = .delete(:limit) || false = ..active.limit(limit) if block_given? .each do || yield() end else content_tag(:div, :class => "spud-banner-set #{[:wrapper_class]}", 'data-id' => .id) do .map do || if background_image concat(content_tag(:div, :class => "spud-banner #{[:banner_class]}", 'data-id' => .id, :style => "background-image:url('#{..url(:banner)}');"){ if .rich_text content_tag :div, raw(.rich_text), :class => 'spud-banner-rich-text' end }) else concat(content_tag(:div, :class => "spud-banner #{[:banner_class]}", 'data-id' => .id){ (, ) }) end end end end end |