I am using the handlebars template engine with Express. When hitting endpoints without parameters, all my static files are served up. This is not the case when a parameter is included.
app.engine('.hbs', hbs(handlebarsOptions));
app.set('view engine', '.hbs');
app.use(express.static('public'));
Here is the endpoint I am trying to use.
app.get('/projects/:name', function(req, res) {
if(req.params.name === 'batteryapp') {
res.render('project', {name: 'BatteryApp'});
}
});
I have seen an example that apparently works if you use res.sendFile(). However, res.render() must be used when using a template engine.
via Reagan Cuthbertson
No comments:
Post a Comment