Reputation: 67
I'm currently working on web development side project. I have been trying to figure out all the pieces for the last couple of months and have made good progress.
I'm using bootstrap and Backbone on the front end and this is what I have been focusing on lately. This part works well with all the Backbone views being rendered fine.
For the backend I will use Nodejs along with express. I have started looking into it this past week. Currently, I'm trying to serve requests sent to the server with through express.
How can I handle the request and send back a Backbone view that already has a defined HTML page and everything.
I came across Jade which is used with express a lot but I can't get it to work with my backbone views. Also, how does underscore come into the picture. Do I have to choose between underscore and Jade?
I will of course further down the line have data pulled from a database and sent to the backbone views.
Thank you for any input.
Upvotes: 1
Views: 247
Reputation: 46
Underscore (_.template method) and Jade both can, from a template file, render html code which will be sent by express to the client. Since underscore is not express friendly my guess is that you are confusing the client libraries (Used by backbone on the browser) and the server libraries user by nodeJS to answer request calls, if you are rendering templates using underscore with backbone that is done client side and has nothing to do with express.
This article should help you set everything up: http://coenraets.org/blog/2012/10/nodecellar-sample-application-with-backbone-js-twitter-bootstrap-node-js-express-and-mongodb/ and it has source code for you to look at.
Since my guess is you want something functional fast, I would suggest something like sails.js which can save you a lot of time configuring express and making it work. Plus sails.js its built on top of express. https://github.com/balderdashy/sails/
Upvotes: 1