a-ejs

0.0.2 • Public • Published

https://github.com/mde/ejs/issues/262

I find the way to support 'async/await'.

let tempate = 'Hello <%- await getName() %>';
let getName = () => {
  return new Promise( (res, rej) => {
     setTimeout(() => {
        res('John');
     }, 1000)
  })
}
html = await ejs.render(template, {getName});
// Hello John.

HOW TO ?

//  lib/ejs.js  line 523
try {
      // let fn to be async.
      eval(`fn = async function(${opts.localsName}, escapeFn, include, rethrow){${src}}`);
      // fn = new Function(opts.localsName + ', escapeFn, include, rethrow', src);
}catch(e){
  // ....
  // ....
}

Package Sidebar

Install

npm i a-ejs

Weekly Downloads

2

Version

0.0.2

License

Apache-2.0

Last publish

Collaborators

  • acthtml