Created
November 3, 2011 17:58
-
-
Save geirarne/1337213 to your computer and use it in GitHub Desktop.
Helper for HTML5 Boilerplate-style IE conditionals in Middleman with HAML. Thanks to http://ricostacruz.com/2010/haml_and_ie_compatibility.html
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
helpers do | |
def conditional_html(opts={}, &blk) | |
attrs = opts.map { |(k, v)| " #{h k}='#{h v}'" }.join('') | |
[ "<!--[if lt IE 7 ]> <html#{attrs} class='ie6 no-js oldie'> <![endif]-->", | |
"<!--[if IEMobile 7 ]> <html#{attrs} class='iemob7 no-js oldie'> <![endif]-->", | |
"<!--[if IE 7 ]> <html#{attrs} class='ie7 no-js oldie'> <![endif]-->", | |
"<!--[if IE 8 ]> <html#{attrs} class='ie8 no-js oldie'> <![endif]-->", | |
"<!--[if IE 9 ]> <html#{attrs} class='ie9 no-js oldie'> <![endif]-->", | |
"<!--[if (gt IE 9)|!(IE)]><!--> <html#{attrs} class='no-js'> <!--<![endif]-->", | |
capture_haml(&blk).strip, | |
"</html>" | |
].join("\n") | |
end | |
end |
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
!!! 5 | |
!= conditional_html(:lang => 'no-NB') do | |
%head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment