Sha256: b65122048886bc6dcd56bfcd48c59ac29b6b38201e1916ec9cc179b360f92aca

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

module NivoHelper
  # 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.
  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?
      content_tag_string(:div, "", options, escape)
    elsif block_given?
      content_tag_string(:div, capture(&block), options, escape)
    else
      content_tag_string(:div, content_or_options, options, escape)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nivo-rails-1.0.0 app/helpers/nivo_helper.rb