question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding the ability to return promises if a callback is not supplied to the renderFile function

var renderedString = await ejs.renderFile(filepath, {data:'data'}, {options:options})

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
niftylettucecommented, Oct 5, 2017

Would love to see this, in the meanwhile you can use util.promisify:

const { promisify } = require('util');
const ejs = require('ejs');

const renderFile = promisify(ejs.renderFile).bind(ejs);

(async () => {
  try {
    const str = await renderFile('test');
    console.log(str);
  } catch (err) {
    throw err;
  }
})();

Thoughts on adding this to the docs/README in the meanwhile @RyanZim?

Also I don’t see ejs.renderFile mentioned in the docs on the website at all, maybe we should add that to the docs section and also a note about Promise support.

2reactions
RyanZimcommented, Aug 17, 2017

@jdalrymple This would need to be in the next major release, as we currently support all the way back to Node 0.10. We’re considering a major release, and if we did do such a release, we’d definitely consider this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PROMISE Support Center
Tech Support Contact Information: ; Promise Global Support email: support@promise.com. PROMISE U.S.A.. Phone : +1 (408) 645-3469. Phone : +1 (408) 876-5886 ...
Read more >
Promises | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end ... A promise represents the eventual result of an asynchronous operation....
Read more >
Promise support definition and meaning - Collins Dictionary
If you support someone or their ideas or aims, you agree with them, and perhaps help them because you want them to succeed....
Read more >
Promise - JavaScript - MDN Web Docs
The Promise object represents the eventual completion (or failure) of an ... used to wrap functions that do not already support promises.
Read more >
PROMISe - PA Department of Human Services
​PROMISe. Please use the links below to find the information you need. ... Provide high-quality supports and protections to vulnerable Pennsylvanians.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found