有关预标记

时间:2016-06-03 13:40:29

标签: html pug

我有这样的Jade代码:

pre='<!DOCTYPE html>\n<html lang="en">\nfoo bar\n</html>'

它呈现如下:

<!DOCTYPE html>
<html lang="en">
foo bar
</html>

我怎样才能实现这样的目标:

pre='<!DOCTYPE html>\n'
    +'<html lang="en">\n'
    +'foo bar\n'
    +'</html>'

或者像这样:

pre="""<!DOCTYPE html>\n"""
    """<html lang="en">\n"""
    """foo bar\n"""
    """</html>"""

更新 我尝试在jade-syntax-docs中使用以下代码,正常工作

   pre
    | <!DOCTYPE html>
    | <html lang="en">
    | foo bar
    | </html>

enter image description here

但我的测试网站中无效。我的网站由 express generator 生成。 它呈现如下:

enter image description here

和html是这样的:

enter image description here

如果jade版本很重要,那就是package.json

{
  "name": "nodejs-crud",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

顺便说一下,我使用bootstrap

4 个答案:

答案 0 :(得分:1)

你也可以这样做:

function () {
    var a;
    console.log(a);
    //if (a === b){ console.log('A and B are Undefined'); }//1)b is an error|2)
    //if((typeof a) !== (typeof b)){ console.log('A is not B'); }//b is an error
    //if(a && b){ console.log('Both a and b exist'); }//b is an error
    //if(a || b){ console.log("a OR b exists"); }//b is an error
    //if(a){ console.log('a exists'); }//A is not an error but does not write
    //if(b){ console.log('b exists'); }//b is an error
    //if(!a){ console.log('a exists but has no value'); }//a exists, but has no value, so writes
    //if(!b){ console.log('b exists but has no value'); }/*b is an error*/ 
}    

答案 1 :(得分:0)

试试这个:

-var myHtml='<!DOCTYPE html>\n'
-myHtml+='<html lang="en">\n'
-myHtml+='foo bar\n'
-myHtml+='</html>'
pre=myHtml

或者这个:

-var myHtml='<!DOCTYPE html>\n'+
- '<html lang="en">\n'+
- 'foo bar\n'+
- '</html>'
pre=myHtml

答案 2 :(得分:0)

您可以像使用管道|一样使用,但更适合您的问题的解决方案是在.标记附加一个点pre。你可以保留缩进。如果您想进行一次换行,建议使用管道。

pre.
    yo
    this is
    preformatted
    text

将输出

<pre>yo
this is
preformatted
text</pre>

example

答案 3 :(得分:0)

顺便说一句,这可能是另一种解决方案:

-
  var myHtml='<!DOCTYPE html>\n'+
  '<html lang="en">\n'+
  'foo bar\n'+
  '</html>'

pre=myHtml