I tried to register handlebar on my express node application, but seems like it doesn't work
const express = require('express');
const hbs = require('hbs');
const expressHbs = require('express-handlebars');
const app = express();
app.engine('.hbs', expressHbs({ defaultLayout: 'layout', extname: '.hbs' }));
app.set('view engine', 'hbs');
hbs.registerHelper('if_equal', function(a, b, opts) {
if (a == b) {
return opts.fn(this)
} else {
return opts.inverse(this)
}
});
In .hbs file I run this code
x is "my_string"
x isn't "my_string"
Then I received this error
Error: Missing helper: "if_equal" handlebars
via sinusGob
No comments:
Post a Comment