npm

Check out our latest tech talk, "JavaScript Supply Chain Security" presented by VP of Security, Adam Baldwin.Watch it here »

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

install

npm i a-ejs

Downloadsweekly downloads

8

version

0.0.2

license

Apache-2.0

last publish

collaborators

  • avatar
Report a vulnerability