egg-view-arttemplate

    2.0.2 • Public • Published

    egg-view-arttemplate

    egg view plugin for arttemplate.

    Install

    $ npm i egg-view-arttemplate --save

    Usage

    // {app_root}/config/plugin.js
    exports.arttemplate = {
      enable: true,
      package: 'egg-view-arttemplate',
    };
     
    // {app_root}/config/config.default.js
    exports.view = {
      mapping: {
        '.html': 'arttemplate',
      },
    };
     
    // arttemplate config
    exports.arttemplate = {
      escape: true,
      debug: false,
      bail: true,
      cache: true
    };

    Create a arttemplate file

    // app/view/hello.arttemplate
    hello <%= data %>

    Render it

    // app/controller/render.js
    exports.arttemplate = async ctx => {
      await ctx.render('hello.html', {
        data: 'world',
      });
    };

    Layout

    You can render a view with layout also:

    // app/view/layout.html
    {{each target}}
        {{$index}} {{$value}}
    {{/each}}
     
    // app/controller/render.js
    exports.arttemplate = async ctx => {
      const locals = {
        data: 'world',
        target: [1, 2, 3]
      };
     
      const viewOptions = {
        cache: false
      };
     
      await ctx.render('hello.html', locals);
    };

    Configuration

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

    Questions & Suggestions

    Please open an issue here.

    License

    MIT

    Install

    npm i egg-view-arttemplate

    DownloadsWeekly Downloads

    2

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    8.26 kB

    Total Files

    7

    Last publish

    Collaborators

    • jamesliauw