Say I have two variables (value1 and value2) and either could be nil, how can I create an element using XmlMarkup and only add the attributes that are not nil?
If I do this
xm = Builder::XmlMarkup.new
xm.item(:attribute1=>value1, :attribute2=>value2)
and both value1 and value2 are nil, I still get
<item attribute1="", attribute2=""/>
I have also tried to add the attributes after creating the element but had no success and I cannot figure out if this is even supported.
If it is not already apparent, I am a complete ruby beginner so any input would be appreciated.