Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add ShowFor.show_for_class configuration option #39

Closed
wojtekmach opened this Issue · 1 comment

2 participants

Wojtek Mach Carlos Antonio da Silva
Wojtek Mach

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.

Carlos Antonio da Silva
Collaborator

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

Vasiliy Ermolovich nashby referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Vasiliy Ermolovich nashby referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.