0.0.2 • Published 7 years ago

a-ejs v0.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
7 years ago

https://github.com/mde/ejs/issues/262(the async/await ejs.)

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){
  // ....
  // ....
}
0.0.2

7 years ago

0.0.1

7 years ago