Module: NivoHelper

Defined in:
app/helpers/nivo_helper.rb

Instance Method Summary collapse

Instance Method Details

#nivo_slider(content_or_options = nil, options = {}, escape = false, &block) ⇒ Object

Convenient helper to create a div for your slider. The method’s definition is similar to Action View’s ‘content_tag` helper. It doesn’t escape the given content by default though.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/nivo_helper.rb', line 5

def nivo_slider(content_or_options = nil, options = {}, escape = false, &block)
  # We are just keeping the two arguments to match Action View's
  # definition of `content_tag` but the first argument isn't
  # considered as the content if it's a Hash object.
  if content_or_options.kind_of?(Hash)
    options.merge!(content_or_options)
  end

  options[:class] ? options[:class] << " nivoSlider" : options[:class] = "nivoSlider"
  options[:id] ||= "slider"

  if content_or_options.kind_of?(Hash) && !block_given?
    (:div, "", options, escape)
  elsif block_given?
    (:div, capture(&block), options, escape)
  else
    (:div, content_or_options, options, escape)
  end
end