2012-01-08 61 views
2

下面是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. 

没有关于什么是当地人在这里的目的解释?什么是当地人?

谢谢。

回答

2

例如,

  1. < %= render :partial => "account" %>

    这意味着已经有一个名为@account一个实例变量的部分,你通过。

  2. <%= render :partial => "account", :locals => { :account => @buyer } %>

    这意味着你通过所谓@buyer到“帐户”部分的本地实例变量,并在“账户”变量部分被称为“帐户”。换句话说,散列{ :account => @buyer }用于:locals仅用于将局部变量传递给partial。你也可以用相同的方式使用关键字。

<%= render :partial => "contract", :as => :agreement

这是一样的:

<%= render :partial => "contract", :locals => { :agreement => @contract }