Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE conditional statements in Jade template engine

How can I convert following IE conditional statements in JADE language :

<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->

I have tried following but it is not working:

//if IE 8
    html lang="en"  class="ie8"
//if IE 9
    html lang="en" class="ie9"
//if !IE
    html lang="en"
// <![endif]

It is showing following output :

<!--if IE 8html lang="en"  class="ie8"
-->
<!--if IE 9html lang="en" class="ie9"
-->
<!--if !IEhtml lang="en"
-->
<!-- <![endif]-->

Can some one guide me how it can be rectified.

like image 706
Simpanoz Avatar asked Dec 31 '13 07:12

Simpanoz


People also ask

Is Jade and pug same?

js, also known as PUG, is a Javascript library that was previously known as JADE. It is an easy-to-code template engine used to code HTML in a more readable fashion. One upside to PUG is that it equips developers to code reusable HTML documents by pulling data dynamically from the API.

How do you comment on Jade?

As written in the comment documentation, you can either use // which will translate to a HTML comment or //- which won't be visible in the outputted HTML code. I have used //- test comment this comment is outputted on source view ctrl+u on browser.

What is pug HTML?

Pug is a template engine for Node and for the browser. It compiles to HTML and has a simplified syntax, which can make you more productive and your code more readable. Pug makes it easy both to write reusable HTML, as well as to render data pulled from a database or API.


1 Answers

Support for the //if IE 8 conditional comment syntax was removed few months ago: Git Commit
Version 0.35 was the last version to support them; v1.0 is the first release after the removal.


I've been using the literal style @Jayram uses; only differences being conditional logic à la h5bp and the closing html tag:

| <!--[if IE 8]>         <html lang="en" class="lt-ie9"> <![endif]-->
| <!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->

Note: Remember to close the document with | </html> since the initial html tag is not Jade's self-closing syntax.

like image 61
Jordan Kelly Avatar answered Sep 28 '22 19:09

Jordan Kelly