K
K
komarevtsev2016-09-19 21:31:17
JavaScript
komarevtsev, 2016-09-19 21:31:17

How to include handlebars in .hbs template?

I am using the handlebars template engine in my express application.
All templates have .hbs extension hbs site and the template is not rendered. there are no errors in the console. I insert the same thing into a normal html page - everything works. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-09-19
@maxfarseer

Are you using express? If yes, then you need express-handlebars
You also need to set handlebars as a "template engine".

app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'hbs'); //в офф.доке используют расширение handlebars

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question