Skip to content

Instantly share code, notes, and snippets.

@jcypret
Created June 20, 2013 04:58
Show Gist options
  • Save jcypret/5820400 to your computer and use it in GitHub Desktop.
Save jcypret/5820400 to your computer and use it in GitHub Desktop.
IE Conditional Comments HAML
# Implements the Paul Irish IE conditional comments HTML tag--in HAML.
# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
# http://ricostacruz.com/2010/haml_and_ie_compatibility.html
def cc_html(options={}, &blk)
attrs = options.map { |(k, v)| " #{h k}='#{h v}'" }.join('')
[ "<!--[if lt IE 7 ]> <html#{attrs} class='ie6'> <![endif]-->",
"<!--[if IE 7 ]> <html#{attrs} class='ie7'> <![endif]-->",
"<!--[if IE 8 ]> <html#{attrs} class='ie8'> <![endif]-->",
"<!--[if IE 9 ]> <html#{attrs} class='ie9'> <![endif]-->",
"<!--[if (gt IE 9)|!(IE)]><!--> <html#{attrs}> <!--<![endif]-->",
capture_haml(&blk).strip,
"</html>"
].join("\n").html_safe
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment