Reputation: 187
1) Can I render a view with Express without using any template file like jade?
I'm building a real-time chat system for Mobile Devs (cross-platform, so it's a web app) with Node, Express & Socket.io, and the server code core will be build for dispatch messages, user's requests & so on, I don't need to have a view but the result of the functions, because the view is already running on the device.
Upvotes: 1
Views: 488
Reputation: 85
If you just want to send the results of functions, you can simply send the response without using a template by calling the .end()
method (documentation) of the response
object that Node passes. An example:
function onRequest( request, response ) {
functionResult = someFunctionYouWantToCall();
response.end( functionResult );
}
Upvotes: 0
Reputation: 382092
That's not really rendering, just serving.
You can send a file as answer using res.sendfile :
res.sendfile("pathToYourFile.html");
Upvotes: 3