Created
March 16, 2011 12:31
-
-
Save jasp/872411 to your computer and use it in GitHub Desktop.
Helper for smart conditional handling of html element in html5 supporting various IE versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
# Helper for html element in haml using this method: | |
# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither | |
def html_tag(lang = "en") | |
str = '<!--[if lt IE 7 ]> <html lang="' + lang + '" class="no-js ie6"> <![endif]-->' | |
str << '<!--[if IE 7 ]> <html lang="' + lang + '" class="no-js ie7"> <![endif]-->' | |
str << '<!--[if IE 8 ]> <html lang="' + lang + '" class="no-js ie8"> <![endif]-->' | |
str << '<!--[if IE 9 ]> <html lang="' + lang + '" class="no-js ie9"> <![endif]-->' | |
str << '<!--[if (gt IE 9)|!(IE)]><!-->' | |
precede str do | |
haml_tag :html, :class => "no-js", :lang => lang do | |
haml_concat "<!--<![endif]-->" | |
yield | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment