I am trying to rewrite some code that was written in jade
. I need to use express-handlebars
or something else that does not alter the entire structure of html file. My question is: how to pass parameters in the new version, for example, the following one which is user
?
The old working version using jade
:
app.js
var router = require('express').Router();
router.get('/', function(req, res) {
res.render('index', {user: req.user});
});
index.jade
block content
if (user)
p You are currently logged in as #{user.username}
else
p You are currently not logged in. Please login or register...
The new version using handlebars
:
index.handlebars
<div class="content"></div>
So what should I write in the new index.handlebars
file and/or what to change in app.js
in order to display the user.username
correctly? I am quite new to this so I appreciate anything that helps.
via tic30
No comments:
Post a Comment