Search code examples
slim-langhtml5boilerplate

How to conver the following HTML IE conditionals into Slim?


Can't figure out how to conver the IE conditionals typically seen at the top of an HTML page into Ruby Slim:

<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->

Anyone know how to do the coversion to Slim?


Solution

  • The following fragment should be enough:

    doctype html
    /![if lt IE 7] <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""
    /![if IE 7] <html class="no-js lt-ie9 lt-ie8" lang=""
    /![if IE 8] <html class="no-js lt-ie9" lang=""
    /! [if gt IE 8]><!
    html.no-js lang="" 
      /! <![endif]
    

    There is a nice tool https://html2slim.herokuapp.com/ that converts HTML into Slim, however it isn't ideal and sometimes do it incorrectly.

    Also there is a Ruby gem that you can use for converting HTML files into Slim ones (https://github.com/slim-template/html2slim).