art-async-template
TypeScript icon, indicating that this package has built-in type declarations

4.13.4 • Public • Published

art-async-template

NPM Version NPM Downloads Node.js Version

English document | 中文文档

This is a fork of original art-template project. It extends functionality by adding async/await calls functions inside templates. For example, if you import in art-template object async function that use I/O, you can use it in template.

const art = require('art-async-template');
art.defaults.imports.doAsync = async function () {
    return await asyncProcedure();
};

In template use this:

<%= await $imports.doAsync() %>

Profit! Also, it can be applied with methods of render data

class Test {
    i = 0;

    async doAsync() {
        // some code
    }
}

const art = require('art-async-template');
var fn = await art.compile(path.join(__dirname, 'test.art'));
var html = await fn({ test: new Test() });

In template use this:

<% await test.doAsync() %>

/art-async-template/

    Package Sidebar

    Install

    npm i art-async-template

    Weekly Downloads

    2

    Version

    4.13.4

    License

    MIT

    Unpacked Size

    62.3 kB

    Total Files

    28

    Last publish

    Collaborators

    • appter-lab