Inputs With Class plugin

Plugin details

Inputs_with_class automatically applies best-practice (universal standard) css naming conventions to all rails generated form elements, giving your css developer full style control of forms right out of the starting gates.

Websitehttp://ror.leewbutler.com/2008/04/inputswithclass.html Repositorygit://github.com/leewbutler/inputs_with_class.git Author Lee Butler Tags input LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/leewbutler/inputs_with_class.git

* Rails generated select lists automatically get classed as 'single' or 'multiple'.

        < select class='multiple' multiple='multiple' size='2' >
        < select class='single'>
    


* Rails generated tags automatically get classed for their 'type' value.

        < input class='password' type='password'/>
        < input class='checkbox' type='checkbox'/>
        < input class='button' type='button'/>
        < input class='hidden' type='hidden'/>
        < input class='submit' type='submit />
        < input class='image' type='image'/>
        < input class='radio' type='radio'/>
        < input class='file' type='file' />
        < input class='text' type='text'/>
    


* Avoid naming conflicts with your existing css classes by adding an optional INPUTS_WITH_CLASS_PREFIX in the config block of your config/environments.rb.

        INPUTS_WITH_CLASS_PREFIX = 'bacon-'
        


Gets you this....

        < input type="text"  class="bacon-text" />
        < input type="radio" class="bacon-radio" />
   


* Generate a starter stylesheet with all related classes and some basic default styles. From the command line in your app root...

        rake inputs_with_class_css
      


* Plays nice with any ad-hoc helper classing you do, so you get...

      class="yourclass inputswithclassclass"
    


* When the time comes, and you suddenly decide to get unclassy again just pass in

      :class => false
  


* 25 tests confirm functionality in all relevant rails helpers. From the command line in your app root...

        cd vendor/plugins/inputs_with_class
        rake test
    


* Heads up for these gotchas when the INPUTS_WITH_CLASS_PREFIX is added or changed.

* Then names in your stylesheet need to be manually changed to match.
* The server needs to be restarted for the prefix to register.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago