Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js JADE linebreaks in source?

Tags:

node.js

pug

I wonder, why i don't see any linebreaks in my sourcecode if i parse my jade template. It looks like this:

!!! 5
html
head
    title= title
    link(rel='stylesheet', href='/stylesheets/css.css')
    link(rel='stylesheet', href='/stylesheets/blitzer/jquery-ui-1.8.10.custom.css')
    link(rel='stylesheet', href='/stylesheets/table_jui.css')

    script(type="text/javascript", src="/javascripts/jquery.min.js")
    script(type="text/javascript", src="/javascripts/jquery-ui.min.js")
    script(type="text/javascript", src="/javascripts/jquery.jwNotify.js")
    script(type="text/javascript", src="/javascripts/jquery.dataTables.min.js")
    script(type="text/javascript", src="/javascripts/js.js")

body!= body

Now my sourcecode looks like this:

<!DOCTYPE html><html><head><title>Express v2</title><link rel="stylesheet" href="/stylesheets/css.css"><link rel="stylesheet" href="/stylesheets/blitzer/jquery-ui-1.8.10.custom.css"><link rel="stylesheet" href="/stylesheets/table_jui.css"><script type="text/javascript" src="/javascripts/jquery.min.js"></script><script type="text/javascript" src="/javascripts/jquery-ui.min.js"></script><script type="text/javascript" src="/javascripts/jquery.jwNotify.js"></script><script type="text/javascript" src="/javascripts/jquery.dataTables.min.js"></script><script type="text/javascript" src="/javascripts/js.js"></script></head><body></body></html>

Would be fine to see line breaks in sourcecode to debug or not? Anyone has an ideo, how i can manage this? Thx for info!

like image 265
ayk Avatar asked Jun 28 '11 09:06

ayk


2 Answers

Sometimes, you want to see pretty html output. To un-uglify your Jade output, pass the pretty option to the compiler in your app.js:

app.set('view options', { pretty: true });
like image 138
Jonathan Julian Avatar answered Nov 06 '22 10:11

Jonathan Julian


Because Jade doesn't compile any line breaks into your html source by default.

It's just sending unneccesary bytes to the client slowing download speed and increasing bandwidth consumption.

Similar Question: Express and pretty HTML

like image 38
Raynos Avatar answered Nov 06 '22 09:11

Raynos