论坛首页 Ruby版 rails

请教render sub templates 和 render partial的区别

浏览 462 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
最后更新时间:2008-08-06 关键字: render
sub templates被rails core team遗忘了,最好不要再用
http://www.jroller.com/obie/entry/don_t_use_sub_templates



从rails的文档上看:
1 render partial: most commonly used together with Ajax calls
2 Using sub templates allows you to sidestep tedious replication and extract common display structures in shared templates

但是好像区别不是很大,但是使用的时候,
前者:
render :partial => "shared/show_prop_defs", :locals => {:propable=>@project}

后者:
render "shared/_show_prop_defs", {:propable=>@project}


你喜欢哪一个?
   
最后更新时间:2008-08-06
一看到这种主->从关系的render的时候,我立马想到用partial,根本没想过第二种方式。要是楼主能教下孰优孰劣就好了。。。
   
0 请登录后投票
最后更新时间:2008-08-07
sub templates被rails core team遗忘了,最好不要再用 http://www.jroller.com/obie/entry/don_t_use_sub_templates
   
0 请登录后投票
最后更新时间:2008-08-10
sub templates从来就没有用过。
一直都是用partial的,不过partial只能用于_xx.html.erb文件,不能指向一个action,有些遗憾,也觉得有时候用起来有些不方便。
   
0 请登录后投票
最后更新时间:2008-08-11
从来没用过后者。
   
0 请登录后投票
论坛首页 Ruby版 rails

跳转论坛:
JavaEye推荐