\nfoo bar\n' and it...">

Jade syntax about multiple lines of string in pre tag

I have a jade code:

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

and it looks like this:

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

How can I achieve something like this:

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

or like this:

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

Update: I tried the following code in jade-syntax-docs , it works !

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

enter image description here

But this does not work on my test site. My site is generated by an express generator . It looks like this:

enter image description here

and html:

enter image description here

If the jade version matters 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"
  }
}

By the way, I use bootstrap.

+4
source share
4 answers

You can also do this:

pre
| <!DOCTYPE html>
| foo bar
| </html>
0
source

Try the following:

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

Or that:

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

|, , , , - . pre. . , .

pre.
    yo
    this is
    preformatted
    text

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

0

This could be another solution:

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

pre=myHtml
0
source

All Articles