Passing Variables to a sub template


#1

Hi,

I must be missing something very basic here.

I have a parent template and I am calling a sub template like…

<%= render( :partial => “window_title_bar”, {“heading” => “Product
Details”}) %>

and in the sub template (_window_title_bar.rhtml), i am doing

Heading: <%= heading %>

but I am getting syntax error in the master template at line

<%= render( :partial => “window_title_bar”, {“heading” => “Requirement
Details”}) %>

Any help is appreciated. Thanks in Advance.

Pradeep


#2

Pradeep

 >  render( :partial => "window_title_bar", {"heading" =>

“Requirement Details”})

You forgot the ':locals => ’ part. It should read:
> render( :partial => “window_title_bar”, :locals => {“heading” =>
“Requirement Details”})

See
http://api.rubyonrails.com/classes/ActionController/Base.html#M000206

Alain


#3

On Apr 21, 2006, at 04:54 PM, Pradeep S. wrote:

but I am getting syntax error in the master template at line

<%= render( :partial => “window_title_bar”, {“heading” => “Requirement
Details”}) %>

You need to specifically tell the render method that you are passing
in local values for the partial template to use:

<%= render( :partial => “window_title_bar”, :locals => {“heading” =>
“Requirement Details”}) %>

I also recommend using symbols whenever you can, so I would actually
use this version:

<%= render( :partial => “window_title_bar”, :locals => {:heading =>
“Requirement Details”}) %>

-Brian