I am looking into Backbone JS and getting a little confused. I am used to compiling my page html on the server-side (using JADE) and then interacting with these elements using jQuery on the client-side. A lot of the backbone examples suggest starting from a blank html body and rendering content on the client-side.
This seems really strange to me!
Do I have to use client-side templating?
Can I use BackboneJS to control pre-written server-side compiled html?
The typical way of using Backbone is to do things client-side. You use client-side template rendering to bind model values to your small view templates. It is an approach to turning HTML/JS into a application development platform with an actual component model.
BUT, that doesn’t mean that you can’t or shouldn’t mix your worlds.
For example, I use Backbone with Rails. My Rails view renders server-side HTML which includes Backbone logic/views. Then, all of my AJAX-style view rendering happens using Backbone with models, views and templates and the models talk to JSON services that live in the Rails backend. The user doesn’t see a page load until they need to leave the page to do something else. The experience is quite nice.
You can certainly take that example and render your templates server-side. I wouldn’t go as far as to render every instance of the template server-side because templating engines (including the one built into Backbone/Underscore) are so powerful. But, if you wanted to seed your templates with server-side rendering, I could see how that might be useful.