Search code examples
html5boilerplateslim-lang

Creating HTML5 Boilerplate conditional HTML classes in Slim


HTML5 Boilerplate uses the following conditional <html> classes:

<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>

I'm wondering how I can reproduce this in a Slim-based template.

Here's what I have so far:

doctype html
/! paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
/[ if lt IE 7 ]
    html class="no-js ie6" lang="en"
/[ if IE 7 ]
    html class="no-js ie7" lang="en"
/[ if IE 8 ]
    html class="no-js ie8" lang="en"
/[ if (gte IE 9)|!(IE) ]
    html class="no-js" lang="en"
head

The last conditional is giving me trouble.


Solution

  • Looks like you can use the pipe character to escape processing.

    | <!--[if (gte IE 9)|!(IE)]<!-->
       <html class="no-js" lang="en"> <!--<![endif]-->
    

    See the Line Indicators section of the API docs.