use*_*363 3 ruby-on-rails render
这是渲染的API定义:
render(options = {}, locals = {}, &block)
Returns the result of a render that’s dictated by the options hash. The primary options are:
:partial - See ActionView::Partials.
:file - Renders an explicit template file (this used to be the old default), add :locals to pass in those.
:inline - Renders an inline template similar to how it’s done in the controller.
:text - Renders the text passed in out.
Run Code Online (Sandbox Code Playgroud)
这里没有关于当地人的目的的解释?当地人干什么?
谢谢。
例如:
<%= render :partial => "account" %>
这意味着已经有一个@account为部分调用的实例变量,并且您将其传递给部分。
<%= render :partial => "account", :locals => { :account => @buyer } %>
这意味着您将调用的本地实例变量传递@buyer给account部分,并且部分中的变量account称为@account。即,哈希{ :account => @buyer }仅:locals用于将局部变量传递给部分变量。as您也可以以相同的方式使用关键字:
<%= render :partial => "contract", :as => :agreement
与以下内容相同:
<%= render :partial => "contract", :locals => { :agreement => @contract }
| 归档时间: |
|
| 查看次数: |
3423 次 |
| 最近记录: |