开发者

Templates for use in Rails and JavaScript

开发者 https://www.devze.com 2023-04-12 10:20 出处:网络
I\'m currently adding Backbone.js to an existing Ruby on Rails application. The objective is todisplay, filter and manipulate some data purely on the client side. I am currently struggling in not dupl

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号