pug

View is not change after render .pug file from express

时间秒杀一切 提交于 2019-12-23 04:35:40
问题 I have some problem that the html view is not change after render the pug file,after getting the server response. The code is following app.set('view engine', 'pug'); app.set("views", require('path').join(__dirname, "views")); app.post('/login', function(req, res, next) { console.log(req.body); checkExistanceOfuser(req.body.username, req.body.password, function(err, flag, data) { console.log(err); if (err) { res.send({ err: 'SOME_DATABASE_ERROR' }) } else { if (flag) { req.session.user = data

What does 'TypeError: Cannot read property '_locals' of undefined' mean?

陌路散爱 提交于 2019-12-23 01:55:46
问题 I'm doing this tutorial on teamTreeHouse https://teamtreehouse.com/library/express-basics/using-templates-with-express/using-jade-in-your-express-app and I'm getting this error: TypeError: Cannot read property '_locals' of undefined at EventEmitter.render (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\application.js:548:11) at c:\Users\bcarr\Web Projects\LTQ\app.js:12:9 at Layer.handle [as handle_request] (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\layer.js:95

What does 'TypeError: Cannot read property '_locals' of undefined' mean?

廉价感情. 提交于 2019-12-23 01:55:40
问题 I'm doing this tutorial on teamTreeHouse https://teamtreehouse.com/library/express-basics/using-templates-with-express/using-jade-in-your-express-app and I'm getting this error: TypeError: Cannot read property '_locals' of undefined at EventEmitter.render (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\application.js:548:11) at c:\Users\bcarr\Web Projects\LTQ\app.js:12:9 at Layer.handle [as handle_request] (c:\Users\bcarr\Web Projects\LTQ\node_modules\express\lib\router\layer.js:95

How to execute js with Jade?

安稳与你 提交于 2019-12-22 09:56:52
问题 i was wondering how to execute js before rendering? This fails -#{somejs} // Outputs just the js-code p #{somejs()} // Executes the js-code, but doenst render the html // In EJS I just write. But how can i do this with node? <%- somejs() %> // I try to use express-messasges (https://github.com/visionmedia/express-messages) with Jade instead of ejs 回答1: The following both work for me: - var test = Math.sqrt(16); div #{test} or div #{Math.sqrt(25)} If possible, would you please post your somejs

How to generate a pure JavaScript file with Jade

别等时光非礼了梦想. 提交于 2019-12-22 08:10:08
问题 I know that Jade is for producing HTML instead of JavaScript, but for a project I'm working, it would be great, and a huge time saver, if I could do this without adding a pipe in every line: | (function(){ | //Some JavaScript Code | var foo="#{bar}"; | console.log("This a JavaScript file generated with Jade"); | })() The idea is to use the output of this template as the source of a regular JavaScript include like this: <script type="application/javascript" src="foo.generated.js"></script> So

IE conditional statements in Jade template engine

旧时模样 提交于 2019-12-22 05:41:28
问题 How can I convert following IE conditional statements in JADE language : <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> <!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> I have tried following but it is not working: //if IE 8 html lang="en" class="ie8" //if IE 9 html lang="en" class="ie9" //if !IE html lang="en" // <![endif] It is showing following output : <!--if IE 8html lang="en" class="ie8" --> <!--if IE 9html lang="en"

IE conditional statements in Jade template engine

ぃ、小莉子 提交于 2019-12-22 05:41:06
问题 How can I convert following IE conditional statements in JADE language : <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> <!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> I have tried following but it is not working: //if IE 8 html lang="en" class="ie8" //if IE 9 html lang="en" class="ie9" //if !IE html lang="en" // <![endif] It is showing following output : <!--if IE 8html lang="en" class="ie8" --> <!--if IE 9html lang="en"

Jade - Controlling line-breaks in the HTML output

梦想与她 提交于 2019-12-22 04:36:35
问题 I have a simple search form I wish to implement using Jade. form input( type="text" size="16" placeholder="Enter your keywords") input( type="button" value="Search") The output is rendered as: <form> <input type="text" size="16" placeholder="Enter your keywords"> <input type="button" value="Search"> </form> This is perfect except that the line-break is causing a space between my button and the search button. I need no space between the textbox and the button. I need the code to render like

How do you set jade basedir option in an express app? (the “basedir” option is required to use “extends” with “absolute” paths)

左心房为你撑大大i 提交于 2019-12-22 03:00:08
问题 Going through the peepcode nodejs video and recreating the app on the current express/node versions I've ran into a small issue. file structure site - apps - - authentication - - - views - - - - login.jade - - - routes.js - node_modules - public - - images - - javascripts - - stylesheets - routes - views app.js login.jade: extends /views/layout block content form(action='/sessions', method='post') label | Username input(type='text', name='user') label | Password input(type='password', name=

The layout.jade is not working, why?

偶尔善良 提交于 2019-12-22 01:41:40
问题 This is my configure file: The layout.jade does not seem to be working. But the jade is working. I used Chrome to check, and am sure that the layout HTML is not loaded into the page. module.exports = function(app, express, mongoose){ var config=this app.configure(function (){ app.set('views',__dirname+'/views') app.set('view engine','jade') app.set('view options', {layout:true}) app.use(express.bodyParser()) app.use(express.methodOverride()) app.use(express.cookieParser()) app.use(express