7

I use slim as view template engine http://slim-lang.com/

How would you write the following piece of code with slim?

thanks

<!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
ylluminate
  • 12,102
  • 17
  • 78
  • 152
denisjacquemin
  • 7,414
  • 10
  • 55
  • 72
  • Looking briefly at their documentation, it seems that `/!` only allows to write a comment line but it doesn't support "conditional" comments like that. I would encourage you to write a patch for Slim that allows such comments. – Thiago Jackiw Jul 24 '11 at 19:08
  • I [added documentation](http://rdoc.info/gems/slim/frames) to [slim-lang](http://slim-lang.com) to cover this topic. – stonean Jul 24 '11 at 22:08

4 Answers4

13

It should use /!

/![if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]
idrinkpabst
  • 1,838
  • 23
  • 25
8

Looking through the documentation github-slim-template/slim I found:

IE conditional comment /[...]

/[if IE]
  p Get a better browser.

renders as

<!--[if IE]><p>Get a better browser.</p><![endif]-->

In your case you could write:

/[if lt IE 9]
  script src="http://html5shim.googlecode.com/svn/trunk/html5.js"  
crimi
  • 746
  • 1
  • 7
  • 8
6

Looking at Slim's source code for Slim::Parser, it seems that you can do it this way, although I haven't tried.

/[if lt IE 9]
  <script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>
Thiago Jackiw
  • 827
  • 6
  • 10
0

I ran across this question searching for a method to do both downlevel-reveal and downlevel-hidden conditionals in Slim.

First make sure you are clear on the difference between these two types of conditionals. CSS-Tricks has a great post about downlevel-hidden and downlevel-reveal conditionals.

This code creates a downlevel-hidden conditional.

/[if lt IE 9]
  ...

But if you want a downlevel-reveal conditional you need to just write it as you would if you were not working in slim.

<!--[if lt IE 9]><!--> ... <!--<![endif]-->

I encountered this issue while trying to use HTML5 Boilerplate in Slim. This Gist shows my approach to the issue.

If slim has a syntax for writing downlevel-reveal conditionals I am not aware of it.

rb-
  • 2,315
  • 29
  • 41