I am excepting a username from a from with input(name="name").
The name is coming as i have checked with console.log(res.body.name). Even res.send("message") is working but the jade is not working.
My index.js
var express = require('express');
var app = express();
var router = express.Router();
router.post('/', function(req, res){
var user = req.body.name;
if(user) {
console.log('User Exist');
res.render('show_message', {message: "User exist", type: "UserExist"});
}
else {
console.log('User is New');
res.render('show_message', {message: "User Doesn't exist", type: "NoUserExist"});
}
}
module.exports = router;
show_message.jade
html
head
title Person
body
if(type=="LoginSuccess")
h3(style="color:green") #{message}
if(type=="error")
h3(style="color:red") #{message}
if(type == "success")
h3 New person, name: #{person.name}, Registered
if(type == "NoUserExist")
h3(style="color:red") #{Message}
if(type == "UserExist")
h3(style="color:red") #{Message}
The jade is not rendering. A blank webpage is coming.
Variable are case sensitive - {message}
instead {Message}
:
if(type == "NoUserExist")
h3(style="color:red") #{message}
if(type == "UserExist")
h3(style="color:red") #{message}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.