在我的var express = require('express');
var session = require('express-session');
var app = express();
var numConnections = 0;
app.use(session({
cookieName: 'sessionTest',
secret: 'eg[isfd-8yF9-7w2315df{}+Ijsli;;to8',
cookie: {
secure: false,
maxAge: 1000 * 10,
sameSite: true
}
}));
app.use((req, res, next) => {
console.log(req.session.store)
console.log(req.session.ip)
console.log(req.session.useragent)
console.log(req.connection.remoteAddress)
console.log(req.headers['user-agent'])
if (numConnections === 0
// && req.session
) {
req.session.ip = req.connection.remoteAddress;
req.session.useragent = req.headers['user-agent'];
req.session.page_views = 1;
res.send("Welcome to this page for the first time!");
numConnections++;
console.log(req.session);
next();
}
else if (numConnections == 1 &&
req.session.ip === req.connection.remoteAddress
&& req.session.useragent === req.headers['user-agent']
) {
req.session.page_views++;
res.send("You visited this page " + req.session.page_views + " times");
console.log('TEST');
next();
} else {
console.log('There is someone using the app!!!');
return res.sendStatus(401);
}
})
app.listen(3001);
文件中,有以下一行...
dust
我正在传递一个子模板{>"form-row-text-input" nLabel="My name is {name}" nValue=name /}
,它是一个字符串(名字和姓氏)。我想为名称设置样式,所以我想添加一个span标签。但是,我似乎无法做到这一点。
我尝试将名称设置为name
,然后将其传递通过模板,但是它仅被解释为字符串。我尝试了几种组合,但是它们不起作用。
有什么办法可以将子模板包含在<span class="name">name variable</span>
内的html标签中?