开发者

Template engine for Ruby and Javascript

We are building a web page with hashtag navigation. There is lots of data, which comes in as JSON and we use client-side templates (jQuery) to render it. So what are the options for reusable templates on both client-side and server-side (Ruby on rails)? Because we would like to have an option to fallback to a non-hashtag url and in this case server should render the data.

I've seen Mustache.js, but it has poor support for iterating (can't get index) or nested templates and haml-js is not an option because it uses custom tags for loops.

There are also couple of workarounds with using javascript engine on server side, but I'm not sure this will be a good decision.

Any suggeti开发者_开发技巧ons? Thanks.


There are a few projects that claim to make this possible. The latest one that I've heard of is Ice. Its README mentions a few others that you might want to check out too. I haven't personally tried any of these, so I can't give you a recommendation as to how well they work, but I'd love to hear about your experiences with them as I might be attempting this in the near future as well.


After analyzing all the ones I could find, I concluded that this one is most attractive:

https://github.com/cowboyd/handlebars.rb

Because the lastest commit is 4 months ago, which is more recent than any other I could find, because it's using V8 and the real Handlebars.js source, and it has some good design considerations and a good ruby interface.

If I choose to go this route I will be using handlebars.rb

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜