How to debug print an object from jade,Like console.log()
in javascript
Asked
Active
Viewed 1.5k times
3 Answers
12
You can debug with console.log
from jade
like this:
div
- console.log(the_object_you_want_to_log)
div

Michael Recachinas
- 2,739
- 2
- 20
- 29
-
8This does not work for me. No errors, but nothing gets logged. – jbyrd Dec 02 '15 at 20:31
-
1So nothing is getting printed to the console -- even if you were to try printing some random string, e.g., `console.log("test")`? – Michael Recachinas Dec 02 '15 at 21:44
-
Correct, that's exactly what I tried, `console.log("test")` – jbyrd Dec 02 '15 at 21:47
-
What happens if you replace `- console.log...` with `= obj_you_want_to_log`? Another suggestion would be to try having it render to the screen, e.g., `pre #{ JSON.stringify(obj) }`. Let me know if either of those work. – Michael Recachinas Dec 02 '15 at 21:51
-
@jbyrd - i had same problem "No errors, but nothing gets logged" - the solution was to make sure my " - console.log" statement was within a JADE block, such as an exact replacement for a working "p" statement. – codingoutloud Apr 03 '16 at 18:43
-
2If someone wants to use this to print it into the browser's console it won't work because Jade is processed server side so console.log inside Jade will print into server side console not in the browser. – ed-ta May 31 '16 at 19:02
-
How do I see the full context object passed into Jade? – Nick Manning Aug 27 '17 at 20:48
11
This helped me! Able to see whole tree of Object in console.
Start script. from leftmost and just give space or tab according to your template before console.log.
script.
console.log(!{JSON.stringify(Object)})

Ashok Regar
- 111
- 1
- 4
0
You can debug like this
div
= your_debug_data
div
or formatted style like:
code.formattedDebug #{your_debug_data}

Tigin
- 391
- 5
- 19