导轨VS骨干:谁应该负责模板和看法? [英] Rails vs Backbone: Who should be responsible for templates and views?

查看:154
本文介绍了导轨VS骨干:谁应该负责模板和看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为练习,我打算以取代Backbone.js的我的Rails应用程序的所有前置环节。该计划的一部分,包括重新设计的一切权利下到CSS。

As an exercise, I intend to replace all front-facing aspects of my Rails application with Backbone.js. Part of the plan includes redesigning everything right down to the CSS.

我挣扎的问题是委托模板和观点的责任。

The issue I'm struggling with is in delegating responsibility for templates and views.

有没有完全骨干实施新的前端,因此只使用Rails作为API?任何好处

Is there any benefit to implementing the new front-end entirely in Backbone, hence only using Rails as an API?

我如何打击Rails和骨干之间的适当平衡,当涉及到处理应用程序的HTML元素?

How do I strike the right balance between Rails and Backbone when it comes to handling the HTML elements of the application?

推荐答案

由于它似乎没有人会回答张贴到这一点,我将提供我的两分钱的只是一个观点(我在其他地方写左右如何让铁轨和Backbone.js的很好地协同工作问题:<一href=\"http://stackoverflow.com/questions/11918586/rails-and-backbone-working-together#11922573\">rails和骨干一起工作的)。

Since it seems that nobody is going to post an answer to this I'll offer my two cents as just one point of view (I've written elsewhere about the issue of how to get rails and backbone.js to work well together: rails and backbone working together).

大多数人在这种情况下往往会完全放弃轨道的观点,一切都迁移到Backbone.js的。

Most people in this situation will tend to drop the rails views altogether and migrate everything to backbone.js.

这是我在是我的工作,现在的一个项目。

This is what I've done in a project that I'm working on right now.

这是事件的自然过程,特别是一旦你开始习惯了所有复杂的有趣的事情,你可以用Backbone.js的结构和JavaScript的做,就很难回头和实施标准的无状态的HTML页面。

This is the natural course of events, and particularly once you start getting used to all the complex interesting things you can do with backbone.js and structured javascript, it becomes difficult to turn back and implement standard stateless HTML pages.

我在链接到其他上面提到的答案;但是,也有成本完全放弃HTML视图和无国籍层。就我而言,我打算只一次应用程序已经达到了某种程度的功能重新添加纯HTML页面对于非支持JS的浏览器为 GET 请求。我们不会支持 POST PUT 请求,除非用户已经启动Javascript(或者除非他们想要去通过JSON API)。

As I mentioned in my other answer linked to above; however, there are costs to completely abandoning HTML views and the stateless layer. In my case, I intend to add back pure HTML pages for non-js-enabled browsers for GET requests only once the app has reached a certain level of functionality. We won't support POST or PUT requests unless the user has javascript enabled (or unless they want to go through the JSON API).

这是我所取得平衡:访问数据无国籍HTML(无JS),但需要发布/更改数据JS。您的选择将取决于你的使用情况和目标用户不同而不同。

That's the balance I've struck: stateless HTML (no-JS) for accessing data, but JS required for posting/changing data. Your choice will vary depending on your use case and target user.

这是我要提到的另一件事是,如果你已经使用了一段时间的一个项目护栏HTML视图中工作,你可能会为ppared切换到Backbone.js的所需的初始开销未$ P $。这不是简单地交换HAML为ERB:你是从一个无状态的前端有状态1迁移,这是一个潜在的巨大变化(取决于应用程序的复杂性)。我自己是ppared对这种变化的深度位未$ P $,而不得不做的很多的制作切换后让我们的应用程序重回正轨之前赶超。我们做了开关很早,以最少的功能已经在的地方。

The other thing that I would mention is that if you have been working with rails HTML views on a project for some time, you might be unprepared for the initial overhead required to switch to backbone.js. This is not simply swapping HAML for ERB: you are migrating from a stateless front-end to a stateful one, and that is a potentially huge change (depending on the complexity of the app). I myself was a bit unprepared for the depth of that change, and had to do a lot of catching up before getting our app back on track after making the switch. And we made the switch very early, with minimal functionality already in-place.

反正只是一些想法,希望他们帮助。

Anyway just a few thoughts, hope they help.

这篇关于导轨VS骨干:谁应该负责模板和看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆