Add ShowFor.show_for_class configuration option #39

Closed
wojtekmach opened this Issue Apr 15, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

wojtekmach commented Apr 15, 2012

I'm proposing to add .show_for_class global option, to declare the css class of the outer div.

Right now I have following in my initializer:

module ShowFor
  mattr_accessor :show_for_class
  @@show_for_class = nil
end

module ShowForClass
  def show_for(object, html_options={}, &block)
    if ShowFor.show_for_class
      html_options[:class] ||= ""
      html_options[:class] << ' ' + ShowFor.show_for_class
      html_options[:class].lstrip!
    end

    super object, html_options, &block
  end
end

ActionView::Base.send :include, ShowForClass

ShowFor.setup do |config|
  # The tag which wraps show_for calls.
  config.show_for_tag = :dl
  config.show_for_class = 'dl-horizontal'
  # ...
end

The default value could be simply 'show_for'.

If the feature and code looks good for you, I'm happy to make a PR.

Collaborator

carlosantoniodasilva commented Apr 15, 2012

Sounds ok, please go ahead and send us a pull request. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment