2008-03-26
有人用过cell么?
http://rubyforge.org/frs/?group_id=2978&release_id=9650
非常小,源代码一目了然。感觉虽然有点土,但比自己做个module的方式好一点点
号称: 代替发挥component作用的controller, 这样就不需要邪恶的render_component了
A cell acts as a lightweight controller in the sense that it will assign variables and render a view.
cell可以用session, params, request等方法访问 父控制器的对应参量
但其它局部变量和实例变量 默认不会传到cell里面
The controller's instance variables and params hash are not directly available from the cell or its views.
目录结构:
=======================邪恶的component回顾=========================
component 组装页面的使用方式大致如下:
rails似乎没有提供以path/url作component的方式,所以只好用
想要包含外部页面为组件,其中一个办法是用esi:include标签。。。
只有用render_component才能调用其他action及action之上的过滤器并包含其结果,而且很慢 ...
非常小,源代码一目了然。感觉虽然有点土,但比自己做个module的方式好一点点
号称: 代替发挥component作用的controller, 这样就不需要邪恶的render_component了
A cell acts as a lightweight controller in the sense that it will assign variables and render a view.
cell可以用session, params, request等方法访问 父控制器的对应参量
但其它局部变量和实例变量 默认不会传到cell里面
The controller's instance variables and params hash are not directly available from the cell or its views.
目录结构:
app/
models/
views/
helpers/
controllers/
cells/
my_cell.rb #cell 'controller'
my_cell/ #cell 'views'
show.html.erb
...cell可以用application helper,若要使用其他helper需声明,如:class ShoppingCartCell < Cell::Base
helper :product
....
end 使用:<%= render_cell :my_cell, :show %>
=======================邪恶的component回顾=========================
component 组装页面的使用方式大致如下:
render_component :controller=>..., :action=>..., :params=>{...}
rails似乎没有提供以path/url作component的方式,所以只好用
render_component ( ActionController::Routing::Routes.recognize_path("/some/action") ) #how ugly!
想要包含外部页面为组件,其中一个办法是用esi:include标签。。。
只有用render_component才能调用其他action及action之上的过滤器并包含其结果,而且很慢 ...
评论
carlosbdw
2008-05-24
怎么向cell中传参数呢?
carlosbdw
2008-05-16
很不错,一直觉得少这么个东西。
yapi
2008-03-26
相关文档太少了...连个tutorial都没有
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 274 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
有人用过cell么?
怎么向cell中传参数呢?
-- by carlosbdw -
有人用过cell么?
很不错,一直觉得少这么个东西。
-- by carlosbdw -
有人用过cell么?
相关文档太少了...连个tutorial都没有
-- by yapi






评论排行榜