JavaScript Jade(Pug) Html render output

I've recently installed Jade(Pug) on a Mac OS X Yosemite.

I installed the node.js last version and then used the terminal command: $ sudo npm install pug-cli -g

Everything was fine until i had to rendered the file. I created a test.pug file with the default pug code:

doctype html
html(lang="en")
  head
    title= pageTitle
    script(type='text/javascript').
      if (foo) bar(1 + 5)
  body
    h1 Pug - node template engine
    #container.col
      if youAreUsingPug
        p You are amazing
      else
        p Get on it!
      p.
        Pug is a terse and simple templating language with a
        strong focus on performance and powerful features.

and then used the terminal to render it to test it. I used the: $ pug -P test.pug and it rendered to the test.html and the output was like this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
    <script type="text/javascript">if (foo) bar(1 + 5)</script>
  </head>
  <body>
    <h1>Pug - node template engine</h1>
    <div class="col" id="container">
      <p>Get on it!</p>
      <p>
        Pug is a terse and simple templating language with a
        strong focus on performance and powerful features.
      </p>
    </div>
  </body>
</html>

Well now when i want to auto render it and used the -watch feature: $ pug -w test.pug it outputs like this:

<!DOCTYPE html><html lang="en"><head><title></title><script type="text/javascript">if (foo) bar(1 + 5)</script></head><body><h1>Pug - node template engine</h1><div class="col" id="container"><p>Get on it!</p><p>Pug is a terse and simple templating language with a
strong focus on performance and powerful features.</p></div></body></html>

I can't find a fix for this. To everyone else that i'm watching on youtube or other tutorials the output looks with the correct HTML structure but mine is rendered like a minified version.

What can i do to fix this and have it auto-rendered with the correct output in HTML?

Answer:1

The option you’re setting in the first variant (-P) enables output prettification. If you want it on the second variant, just add the flag: pug -P -w test.pug

From the docs:

-h, --help             output usage information
-V, --version          output the version number
-O, --obj <path|str>   JavaScript options object or JSON file containing it
-o, --out <dir>        output the compiled html to <dir>
-p, --path <path>      filename used to resolve includes
-P, --pretty           compile pretty html output
-c, --client           compile function for client-side runtime.js
-n, --name <str>       the name of the compiled template (requires --client)
-D, --no-debug         compile without debugging (smaller functions)
-w, --watch            watch files for changes and automatically re-render
-E, --extension <ext>  specify the output file extension
--name-after-file      name the template after the last section of the file path
                       (requires --client and overriden by --name)
--doctype <str>        specify the doctype on the command line (useful if it
                       is not specified by the template)
Answer:2

Is it possible in js to create a date object that is not affected by timezone? For example i want to set the year "2015", the month "03" and the day "31". var ex = new Date(2015,3,31); If i "print" ...

Is it possible in js to create a date object that is not affected by timezone? For example i want to set the year "2015", the month "03" and the day "31". var ex = new Date(2015,3,31); If i "print" ...

I'm wondering if there is a better (cleaner?) method than my current implementation. I'm currently encoding a PHP SimpleXMLObject (USPS Tracking API) to JSON and looping through said JSON object via ...

I'm wondering if there is a better (cleaner?) method than my current implementation. I'm currently encoding a PHP SimpleXMLObject (USPS Tracking API) to JSON and looping through said JSON object via ...

  1. dynamic jquery dialog
  2. jquery dynamic dialog box example
  3. jquery dynamic dialog example
  4. dynamic jquery ui dialog
  5. jquery dynamic modal dialog
  6. create dynamic dialog jquery
  7. jquery dynamic confirm dialog
  8. dynamic content in jquery dialog
  9. dynamic buttons dialog jquery
  10. jquery dialog dynamic width
  11. jquery dialog dynamic title
  12. jquery dialog dynamic height
  13. jquery dialog dynamic button text
  14. jquery dialog dynamic text
  15. jquery dialog dynamic size
  16. jquery dialog dynamic html
  17. jquery dialog dynamic position
  18. jquery dialog dynamic div
  19. jquery dialog dynamic message

In Javascript (in Chrome devtools console panel and Node.js v0.12.5), I'm getting an incorrect answer for the product of these two large numbers: input: 41962049 * 1827116622 output: ...

In Javascript (in Chrome devtools console panel and Node.js v0.12.5), I'm getting an incorrect answer for the product of these two large numbers: input: 41962049 * 1827116622 output: ...

I'm trying to update my regular React state through Immutable, and got into some few issues. The state isn't deeply nested or it isn't nested from anything other than the state itself, such as { "...

I'm trying to update my regular React state through Immutable, and got into some few issues. The state isn't deeply nested or it isn't nested from anything other than the state itself, such as { "...

  1. updating react state
  2. updating react state array
  3. react updating state from props
  4. react updating state object
  5. react updating state in render
  6. react updating state based on props
  7. react updating state from another component
  8. react updating state directly
  9. updating react nested state properties
  10. updating react component state
  11. updating nested state react
  12. react updating parent state from child
  13. react updating parent state
  14. setstate not updating state react
  15. setstate not updating state react native
  16. updating child component state react
  17. usestate not updating state react
  18. react updating state without setstate