RULES FOR THE VIEW
Our markup should have meaning. We write templates using semantic HTML.
Our style sheets should handle presentation. We don’t use markup to style or use images when CSS will do.
Our templates should be free of client-side code. We unobtrusively attach behavior from our JavaScript files.
Our templates should be easy to read. We consistently indent correctly using spaces instead of tabs, type lines no longer than eighty characters, and extract complex logic to helpers and presenters.
Our templates should be easy to find. We use standard naming conventions and place them in the directory for the related resource (or the layout).
Our markup should be easy for the entire team to modify. We prefer rendering partials over generating markup from Ruby code.
Our technology choices should help, not hinder, the team. We use the templating language and tools that work best for all of us.
Our designs for the Web should work on a variety of devices and browsers. We build for the simplest interactions first and support progressive enhancement.
Our designs for email must work for a wide range of providers. We use HTML tables and images as necessary and always provide a plain-text alternative.
Our application should perform as well as it needs to, when it needs to. We implement the most elegant approach first, then we optimize when necessary.
楼下翻译? :
Use no way as way. Having no limitation as limitation. ーー Bruce on Rails
#5 楼 @cisolarix 我的方法是写一个 helper,在 html 里面用这个 helper 来执行 js 代码:run :init_some_page
#5 楼 @cisolarix 有的时候真的无法做到完全 HTML 与 JavaScript 分开写啊。
啥情形呢?
#6 楼 @linjunhalida 可否举个小例子?
#8 楼 @linjunhalida 如果只是 init_idea_new 里的 js 只是绑定 form 提交时 js code,也可以通过 jquery 里的 on 函数定义吧