You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use async/await in ejs template by passing `{async: true}` in options:
61
+
Since ejs [v2.5.8](https://github.com/mde/ejs/releases/tag/v2.5.8) added support for promise/async-await `renderFile`, you can now use this option with gulp-ejs v4.1.0.
62
+
63
+
You can use async/await in your ejs templates by passing `{ async: true }` in the ejs options hash:
62
64
63
65
```javascript
64
66
constejs=require('gulp-ejs')
65
67
66
-
asyncfunctionblah() { /* async task */ }
68
+
asyncfunctionfoobar() { /* async task */ }
67
69
68
-
gulp.src("./templates/*.ejs")
69
-
.pipe(ejs({blah}, {async:true}))
70
-
.pipe(gulp.dest("./dist"))
70
+
gulp.src('./templates/*.ejs')
71
+
.pipe(ejs({ foobar }, {async:true}))
72
+
.pipe(gulp.dest('./dist'))
71
73
```
72
74
73
-
In template, await will be used to call async functions for example: `<%= await blah() %>`
75
+
Then in your templates use `await` to call async functions. Here's an example:
0 commit comments