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.

How to use include when async option is passed?

See original GitHub issue

I am storing email templates in files and I have header and footer file. I am trying to use async for renderFile with this template:

<%- include('header'); -%>
<h1>
  Title
</h1>
<p>
  My page
</p>
<%- include('footer'); -%>

const options = { async : true }; the includes are replaced with [object object]. how can i use include and async together?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
drewmoorecommented, Jul 19, 2019

This works for my setup:

<%- await include('header'); %>
1reaction
mdecommented, Mar 16, 2019

Ultimately we want to make all the I/O async, so opting into async rendering with the top-level async flag should be enough to make the entire tree async. You shouldn’t have to opt in to includes being async on top of that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

async function - JavaScript - MDN Web Docs - Mozilla
Async functions can contain zero or more await expressions. Await expressions make promise-returning functions behave as though they're ...
Read more >
javascript - Async - passing variables and preserving context
All I want is to pass some of my current state into this task executor. In coffeescript my code looked like this: _metadata...
Read more >
Task asynchronous programming model - Microsoft Learn
Start with the method signature. It includes the async modifier. The return type is Task<int> (See "Return Types" section for more options).
Read more >
std::async - cppreference.com
The function template async runs the function f asynchronously (potentially in a separate thread which might be a part of a thread pool)...
Read more >
Understanding the Event Loop, Callbacks, Promises, and ...
An async function allows you to handle asynchronous code in a manner that appears synchronous. async functions still use promises under the hood ......
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