egg view plugin for handlebars
$ npm i egg-view-handlebars --save
// {app_root}/config/plugin.js
exports.handlebars = {
enable: true,
package: 'egg-view-handlebars',
};
// {app_root}/config/config.default.js
/**
* view
* @member
* @property defaultViewEngine: string setup default view engine
* @property defaultExtension: string template file extension
* @property mapping: Object {string: string}
*/
exports.view = {
defaultViewEngine: 'handlebars',
defaultExtension: '.hbs',
mapping: {
'.hbs': 'handlebars',
},
};
Partials are loaded from app/view/partials
by default, you can define user_message.hbs
and use userMessage
as partial.
Note:
- The file name will be camelized, e.x.
foo_bar > fooBar
,foo-bar > fooBar
- Don't support cascade directory
see config/config.default.js for more detail.
Please open an issue here.