如何在jade中添加HTML标签? [英] How do I put a html tag conditional in jade?

查看:501
本文介绍了如何在jade中添加HTML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

翡翠中,我希望将html标签置于这个方法,它放入

 <! -  [if lt IE 7]> < html class =ie6>百分比抑制率ENDIF]  -  GT!; 
<! - [if IE 7]> < html class =ie7>百分比抑制率ENDIF] - GT!;
<! - [if IE 8]> < html class =ie8>百分比抑制率ENDIF] - GT!;
<! - [if IE 9]> < html class =ie9>百分比抑制率ENDIF] - GT!;
<! - [if(gt IE 9)|!(IE)]><! - > < html class => <! - <![ENDIF] - GT;

位于HTML文件的顶部。



我试过了

  // [if lt IE 7]> < html class =no-js ie6 oldielang =en> <![endif] 
// [if IE 7]> < html class =no-js ie7 oldielang =en> <![endif]
// [if IE 8]> < html class =no-js ie8 oldielang =en> <![endif]
// [if gt IE 8]><! - > < html class =no-jslang =en> <! - <![endif]
head
...



<但是jade忽略了html标签,并且不会在最后写入< / html> 标签。这是无效的HTML,导致IE不显示任何东西。



有没有办法做到这一点?



我想我会在没有办法的情况下使用javascript解决方案。

>此方法适用于关闭html标记:

  !!! 5 
// if if IE 7
< html class =no-js lt-ie9 lt-ie8 lt-ie7>
// if IE 7
< html class =no-js lt-ie9 lt-ie8>
// if IE 8
< html class =no-js lt-ie9>
// [如果gt IE 8]< ;!
html(class =no-js,lang =en)
//<![endif]
head
title = title

body!= body

from: $ / $> $ / $>

更新:



正如指出的那样kumar-harsh 此行为现在已被折旧,如果您需要此功能,您现在应该使用常规html:

  <! -  [if IE]> 
< html class =ie>
<![endif] - >
<![if!IE]>
< html class =not-ie>
<![endif]>
< / html>

来自: https://github.com/visionmedia/jade/issues/1345?source=cc#issuecomment-31920732


In jade, I want to put in a html tag conditional as per this method, which puts in

<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->

at the top of a html file.

I tried

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

but jade ignores the html tag, and doesn't write in the end </html> tag. This is invalid html, and results in IE not displaying anything at all.

Is there any way of doing it?

I'm thinking I'll just use a javascript solution if there isn't a way.

解决方案

This method works, with the closing html tag:

!!! 5
//if lt IE 7
    <html class="no-js lt-ie9 lt-ie8 lt-ie7">
//if IE 7
    <html class="no-js lt-ie9 lt-ie8">
//if IE 8
    <html class="no-js lt-ie9">
// [if gt IE 8] <!
html(class="no-js", lang="en")
    // <![endif]
    head
        title= title

    body!= body

from: https://gist.github.com/kmiyashiro/1140425#comment-675550

Update:

As pointed out by kumar-harsh this behaviour has now been depreciated, if you need this functionality you now should use regular html:

<!--[if IE]>
  <html class="ie">
<![endif]-->
<![if !IE]>
  <html class="not-ie">
<![endif]>
</html>

from: https://github.com/visionmedia/jade/issues/1345?source=cc#issuecomment-31920732

这篇关于如何在jade中添加HTML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆