D
D
Dima Pautov2017-01-26 15:58:10
Node.js
Dima Pautov, 2017-01-26 15:58:10

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

Here is the content of app.js
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}`);

});

What needs to be done to load the markup from the index.hbs file? How to correctly specify paths. Help me to understand

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
emp1re, 2017-01-26
@emp1re

Take their example - https://github.com/ericf/express-handlebars/tree/m...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question