=============================== ie_specific (v 0.1) =============================== Tom Armitage (tom@infovore.org) http://infovore.org 2006-11-14 =============================== SYNOPSIS -------- ie_specific is a Rails plugin that automates the conditional inclusion of CSS and Javascript files that are only to be parsed by the Internet Explorer family of browsers. INSTALLATION ------------ script\plugin install http://ie-specific-rails-plugin.googlecode.com/svn/ie-specific INTRODUCTION ------------ Internet Explorer's implementation of web standards has never exactly been the best, and so it's often necessary to use CSS hacks to ensure that sites display consistently and correctly. Internet Explorer 7 supposedly fixed many of the CSS bugs present in earlier versions; unfortuantely, whilst it has fixed _some_ CSS issues, others remain (and new ones have been introduced). To make matters worse, several of the common CSS hacks used in IE 6 and below now no longer work - the most obvious being the star-HTML hack. As such, writing workarounds for Internet Explorer has become more complex. This plugin makes a standardised approach to IE workarounds simple and consistent to implement in Rails. USAGE ----- [NB: This plugin is designed for a particular way of working, which we happen to think is an effective way for companies with many products to keep their IE hacks in a consistent place. It's a classic piece of opinionated software; if you don't want to work in the manner it demands, this plugin is not for you.] 1) Ensure that all your "standard" .css files are free of hacks; they should be all that is required to produce a standards compliant version of your site. 2) IE hacks should be seperated out into their own files. These files should be named for the appropriate IE condition that they match, eg: ie-5.css # => styles for IE 5 only lte-ie-6.css # => styles for IE browsers versions 6 and below lt-ie-7.css # => styles for IE browsers with a version less than 7 lte-ue-5.5000.css # => styles for browsers with a version less than or equal to 5.5000 (sub-version numbers can get nasty) etcetera. 3) These hacks should be placed in #{RAILS_ROOT}/public/stylesheets/ie_specific . This is not up for debate, though you can choose a different name for the subdirectory if you want to alter the plugin. 4) Any javascripts to only be included in IE browsers should be named similarly (but ending in .js, obviously) and placed into #{RAILS_ROOT}/public/javascripts/ie_specific . Again: not up for debate, unless you want to alter the plugin.. 5) In the of your layout, insert the following helper method: <%= ie_specific_styles_and_scripts %> 6) That's it! Any .css or .js files that should only be used by certain versions of Internet explorer will now be automatically included in an appropriate, standards compliant, accessible manner. The advantages of this method should now be obvious: should any other hacks become necessary, they can be abstracted into their own CSS file and simply dumped in a directory, and will be included automatically.