egg-view-handlebars-x

    2.0.3 • Public • Published

    egg-view-handlebars-x

    suport cache template and recompile partials

    NPM version build status npm download

    egg view plugin for handlebars

    Install

    $ npm i egg-view-handlebars-x --save

    Usage

    // {app_root}/config/plugin.js
    exports.handlebars = {
      enable: true,
      package: 'egg-view-handlebars-x',
      // support cache.
      // attention: the `options` param also will be cached
      cache: true,
    };
    // {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',
      },
    };

    Register Partial

    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

    Configuration

    see config/config.default.js for more detail.

    Questions & Suggestions

    Please open an issue here.

    License

    MIT

    Install

    npm i egg-view-handlebars-x

    DownloadsWeekly Downloads

    2

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    7.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • daifee