RXML partial question

All,

I have a RXML template which renders partial RXML templates within it.

A snippet is below. The “xml” variable is the parent template’s Builder
variable. It is passed into the partial under the name “parent_xml”.

Why can’t I use :locals => {… :xml => xml …} in my call to render
the partial? It seems like if I do use :xml => xml, it doesn’t work,
and I am forced to pass into a local variable with a name other than
“xml”, for example, “parent_xml”.

Thanks,
Wes

========== snippet of main template ================

xml.tbody do
objects.each do |obj|
xml.tr do
render(:partial => ‘common/list_buttons_display’,
:layout => false,
:locals => {:parent_xml => xml,
:buttons => buttons,
:obj => obj}) if buttons_first

========== snippet of RXML partial ================

columns.each do |col_array|
attr_name = col_array[0]
column_display_name = col_array[1]
value = eval(“obj.#{attr_name}”)
column_contents = (column_display_name == ‘Fax Number’ ?
number_to_phone(value, {:area_code => true}) :
value)
parent_xml.td(column_contents, :id => “#{obj.id}_#{attr_name}”)
end

rxml templates automatically instantiate a xml builder object under the
“xml” variable, so if you are passing it from the parent, you are
getting it overriden by the one created at the beginning of the
template.

what i usually do is pass it under another name (parent_xml is perfect)
and then do something like

xml = parent_xml unless parent_xml.nil?

this way you can consistently use the “xml” variable as your root
element throughout all the templates/partials

regards,

javier

Javier,

Thanks. I suspected that xml was the “default variable”.

Wes