Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
02656ac3
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
02656ac3
编写于
9月 12, 2010
作者:
C
Collin Miller
提交者:
Mikel Lindsaar
9月 13, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added documentation for :as and :object in PartialRenderer
Signed-off-by:
N
Mikel Lindsaar
<
raasdnil@gmail.com
>
上级
bca9b84a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
0 deletion
+32
-0
actionpack/lib/action_view/render/partials.rb
actionpack/lib/action_view/render/partials.rb
+32
-0
未找到文件。
actionpack/lib/action_view/render/partials.rb
浏览文件 @
02656ac3
...
...
@@ -26,6 +26,36 @@ module ActionView
# This would first render "advertiser/_account.erb" with @buyer passed in as the local variable +account+, then
# render "advertiser/_ad.erb" and pass the local variable +ad+ to the template for display.
#
# == The :as and :object options
#
# By default PartialRenderer uses the template name for the local name of the object passed into the template.
# These examples are effectively the same:
#
# <%= render :partial => "contract", :locals => { :contract => @contract } %>
#
# <%= render :partial => "contract" %>
#
# By specifying the :as option we can change the way the local variable is namedin the template.
# These examples are effectively the same:
#
# <%= render :partial => "contract", :as => :agreement
#
# <%= render :partial => "contract", :locals => { :agreement => @contract }
#
# The :object option can be used to directly specify which object is rendered into the partial.
#
# Revisiting a previous example we could have written this code.
#
# <%= render :partial => "account", :object => @buyer %>
#
# <% for ad in @advertisements %>
# <%= render :partial => "ad", :object => ad %>
# <% end %>
#
# The :object and :as options can be used together. We might have a partial which we have named genericly,
# such as 'form'. Using :object and :as together helps us.
#
# <%= render :partial => "form", :object => @contract, :as => :contract %>
# == Rendering a collection of partials
#
# The example of partial use describes a familiar pattern where a template needs to iterate over an array and
...
...
@@ -39,6 +69,8 @@ module ActionView
# iteration counter will automatically be made available to the template with a name of the form
# +partial_name_counter+. In the case of the example above, the template would be fed +ad_counter+.
#
# The :as option may be used when rendering partials.
#
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
# just keep domain objects, like Active Records, in there.
#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录