Tag: pug

express/jade get current user in view

I have a simple nodejs/express application by this example. In that view there is checking everyauth.loggedIn variable, but in my application I don’t use everyauth module I use the following code instead: req.session.auth = user; How can I get access to req.session.auth in a view in this case?

How to insert html form element between label tag and text of label tag in jade

I need to generate following html markup in jade <div class=”checkbox”> <label> <input type=”checkbox”> Remember me </label> </div> My try:- .checkbox label Remember me input(type=”checkbox”) generates <div class=”checkbox”> <label> “Remember me ” <input type=”checkbox”> </label> </div> How can we place element “checkbox” infront of “Remember me” label text?

module “require” inside a Jade file

I need to use “fs” module inside a Jade file. No other JS file. When I try: – var js = require(‘fs’) – var downloadfiles = readdirSync(“download”) for f in downloadfiles url loc= D + “/download” + f lastmod= buildDate changefreq daily priority 1.0 I got the error “undefined is not a function”

Inline CSS using Jade templating system

Is there a way to write inline css using Jade for Node? My HTML is: <div class=”column” style=”text-align:center;”></div> but I can’t see any reference to this in the guides.

How do I output view compiler errors generated from Hapi.js views?

Coming from the world of express, if there was an error when compiling a Jade template, the error would output to the browser with details of the template error including line number. I would like to see this level of error detail in Hapi.js when the view template compiler encounters an error. Instead, with Hapi.js, […]

Jade adds empty `style` element to `head`

I’m using Jade as a templating engine for my Express powered node.js application. Maybe it’s late in night, but I can’t figure out where empty style element inserted in resulting HTML. Live example: http://quotation-mark.herokuapp.com/ (noticed that <style type=”text/css”></style> at the very end of head?) Express’ templates setup: app.set(‘views’, settings.projectDir + ‘/views’); app.set(‘view engine’, ‘jade’); app.set(‘view […]

Render table with Jade/Express.js having multiple elements per row

I’m trying to render a table using jade from a simple array of objects. But instead of simply rendering one row per object, I want to render three objects on each row. <table> <thead>…</thead> <tbody> <tr> <td>obj0</td> <td>obj1</td> <td>obj2</td> </tr> <tr> <td>obj3</td> <td>obj4</td> <td>obj5</td> </tr> … </tbody> </table

Toggle active link Bootstrap navbar

I’ve read a lot of posts on the subject, found almost always the same solution but it does not work for me… My problem is as follows : I want to use Twitter Bootstrap 2.3.2 and its navbar, so I include the css and js files. Just before that, I also include jquery. I then […]

How to know the value is empty

If I pass an empty array to jade, how can I know if is empty? Javascript: var data = []; Jade: if(data) table … else table …

Error using Express for NodeJS: 'engine' of object #<View> is not a function

I’m new to nodejs and was wondering if anyone knew how to debug this error: TypeError: Property ‘engine’ of object #<View> is not a function I’ve just installed an express instance after a bit of work getting node/npm installed on an ubuntu box. Any ideas? Here’s my stack trace: 500 TypeError: Property ‘engine’ of object […]

Node.js is the Best Javascript runtime in the world.