a-ejs
v0.0.2
Published
the async/await esj
Downloads
3
Readme
[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){
// ....
// ....
}