Answer the question
In order to leave comments, you need to log in
How to correctly specify the output of the .hbs template?
Good afternoon! Help me understand what I'm doing wrong?
I just want to make a simple content output, static.
Installed express + express-handlebars . I want to set up templates.
There is a description of what and how. But by God, I don't understand.
The directory structure is like this:
views
└── app.js
└── app
├── css
├── js
├── views
└── layouts
└── index.hbs
const express = require('express');
const exphbs = require('express-handlebars');
const app = express();
const port = 3000;
const log = console.log;
app.engine('.hbs', exphbs({
defaultLayout: 'index',
extname: '.hbs'
}));
app.set('view engine', '.hbs');
app.get('/', function(req, res) {
res.render('index');
});
app.listen(port, () => {
log(`Приложение слушает порт: ${port}`);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question