Skip to content

Instantly share code, notes, and snippets.

@jasp
Created March 16, 2011 12:31
Show Gist options
  • Save jasp/872411 to your computer and use it in GitHub Desktop.
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.
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