浏览 2524 次
|
该帖已经被评为良好帖
|
|
|---|---|
| 作者 | 正文 |
|
时间:2008-03-26
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. 目录结构: 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之上的过滤器并包含其结果,而且很慢 ... 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
| 返回顶楼 | |
|
时间:2008-03-26
相关文档太少了...连个tutorial都没有
|
|
| 返回顶楼 |
请登录后投票
|



