Hi, I''m creating a dynamic xml file using builder in Rails, which pulls
from several different related tables. Some of my nodes include
attributes, but some don''t. I would like to find a way to leave out
those attributes that are blank.
My XML now:
<row type="bold" line="4">
<cell>Vermont </cell>
<cell>27%</cell>
</row>
<row type="" line="5">
<cell>Hawaii </cell>
<cell>100%</cell>
</row>
should look like this:
<row type="bold" line="4">
<cell>Vermont </cell>
<cell>27%</cell>
</row>
<row line="5">
<cell>Hawaii </cell>
<cell>100%</cell>
</row>
without the blank type="" attribute.
My .builder includes this:
@table.each do |r|
xml.row(:line => r[0], :type=> r[1]) do
r.each do |i|
xml.cell(i, :column_id => '''')
end
end
end
I can make the value for :type => nil, but I still get the blank
attribute. I tried conditionals inside the node, but that didn''t work.
Any ideas?
Thanks.
--
Posted via http://www.ruby-forum.com/.