Skip to content
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

Allow templates to be rendered without reply #59

Merged
merged 6 commits into from
Oct 6, 2018
Merged

Allow templates to be rendered without reply #59

merged 6 commits into from
Oct 6, 2018

Conversation

robinvdvleuten
Copy link
Contributor

Something you'll need to render a template without a "reply" context. Like a notification email for example. This PR adds fastify.view() just for that.

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!
Can you also add a test to verify the output of fastify.view and update the documentation?

@robinvdvleuten
Copy link
Contributor Author

@delvedor sure! Do you want all the same testcases as for reply.view or only one to confirm that it's working?

@delvedor
Copy link
Member

delvedor commented May 7, 2018

Just one should be fine :)

@robinvdvleuten
Copy link
Contributor Author

@delvedor so it turned out to be more difficult than initially thought. I made the renderer functions returning promises, so they can be used when calling in a non-response aware context (the functions had some send and header calls).

@mcollina
Copy link
Member

CI is failing for Node 6.

I’m somewhat -1 on returning a promise in the renderer. The action was synchronous before and it become asynchronous now.

@robinvdvleuten
Copy link
Contributor Author

@mcollina I brought back the original synchronous functionality (so no breaking changes 💪). The new fastify.render method is still using promises though, is that still a concern?

@mcollina
Copy link
Member

There is no reason to have fastify.render return a promise as it's not an asynchronous operation.

@robinvdvleuten
Copy link
Contributor Author

@mcollina but what about the _readCallback then?

@mcollina
Copy link
Member

You are right. I would go for a callback if there is one, or a Promise if there is none.

@robinvdvleuten
Copy link
Contributor Author

@mcollina I've updated the PR accordingly 👍

@mcollina mcollina merged commit 9f8b110 into fastify:master Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants