I'm currently adding Backbone.js to an existing Ruby on Rails application. The objective is to display, filter and manipulate some data purely on the client side. I am currently struggling in not duplicating the views I have for data on Rails in Backbone. Ideally I will have one canonical/view/template for use in my application.
My rails views are currently in HAML and have some logic embedded in them for displaying data. I spent some time using Mustache on the client side but I really dislike writi开发者_开发百科ng out raw HTML instead of HAML and duplicating the logic found in my rails views.
I am open to any and all suggestions.
I wrote an article on re-using rails views (works with HAML, ERB, etc) in Backbone, here: http://lostechies.com/derickbailey/2011/09/06/test-driving-backbone-views-with-jquery-templates-the-jasmine-gem-and-jasmine-jquery/
There are a few other posts linked from there that will give a bit more detail, too.
精彩评论