-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output of render should be Promise-compatible #251
Comments
You can use temporarily bluebird module.
then in routing we invoke renderAsync method:
|
/CC @philidem @mlrawlings I would like to see a method that returns a promise, but I would prefer to avoid a breaking change. The purpose of returning the template.render({ hello: "world" })
.on('foo', function(e) {
})
.on('error', function(e) {
})
.on('finish', function() {
}) What are your all thoughts on utilizing the native promise implementation to provide a new var template = require("template.marko");
template.renderAsync({ hello: "world" })
.then(function (html) { ... })
.catch(function (err) { ... }); |
I'd rather modify I've seen other libraries such as It would support both template.render({ hello:"world" })
.then(function (html) { ... })
.catch(function (err) { ... }); and template.render({ hello:"world" })
.on('error', function(e) { ... })
.on('finish', function() { ... }) And with async/await you'd be able to do: var html = await template.render({ hello:"world" }) We could also implement a
|
I like the suggestion to implement the |
FYI: it should be sufficient to add the |
NOTE: We want to follow the rules for having a consistent rendering API: #389 That is: template.render({})
.then(function(out) {
out.appendTo(document.body);
}); |
A bit late, just throwing this out there: The Promises/A+ specification requires that if the result is an |
Currently rendering a template returns an
AsyncWriter
, it would be handy though if when a callback is omitted that templates render function returned a promise.If you're using promises already it makes using marko a bit easier.
The text was updated successfully, but these errors were encountered: