@hidoo/express-engine-handlebars
v1.1.0
Published
Handlebars template engine for express.
Downloads
16
Readme
@hidoo/express-engine-handlebars
Handlebars template engine for express.
Installation
npm install --save express @hidoo/express-engine-handlebars
Usage
import express from 'express';
import expressEngineHandlebars from '@hidoo/express-engine-handlebars';
const app = express();
app.set('view engine', 'hbs');
app.set('views', '/path/to/views');
app.engine(
'hbs',
expressEngineHandlebars({
layouts: '/path/to/views/layouts/**/*.hbs',
partials: '/path/to/views/partials/**/*.hbs',
helpers: '/path/to/views/helpers/**/*.js'
})
);
Registering Helpers
example:
export const register = (handlebars) => {
handlebars.registerHelper(
'wrapBrackets',
(value) => new handlebars.SafeString(`[[ ${value} ]]`)
);
};
Test
pnpm test
License
MIT