Fixes issue 33 which requests that there be an option to specify how Builder treats nil values from initialization. Without specifying the explicit_nil_handling option as true, the codebase functions the same way.
b = Builder::XmlMarkup.new
b.tag! "foo", "bar"
yields an output of
<foo>bar</foo>
as does
b = Builder::XmlMarkup.new explicit_nil_handling: false
b.tag! "foo", "bar"
However, when a tag has a nil value, and the option is turned on, it adds a nil="true" attribute to the tag, in order to match the way Rails explicitly denotes nil values when rendering ActiveRecord objects as xml.
b = Builder::XmlMarkup.new explicit_nil_handling: true
b.tag! "foo", nil
Fixes issue 33 which requests that there be an option to specify how Builder treats nil values from initialization. Without specifying the explicit_nil_handling option as true, the codebase functions the same way.
yields an output of
as does
However, when a tag has a nil value, and the option is turned on, it adds a nil="true" attribute to the tag, in order to match the way Rails explicitly denotes nil values when rendering ActiveRecord objects as xml.
yields
commit 430b9762c436f180db8686407b5002cb4f71e8b9 Author: Dermot Haughey hderms@gmail.com Date: Tue Jan 15 19:36:00 2013 -0600
commit b9adb4d916ae1cf897ea2c1f39f5ad0c0def4460 Author: Dermot Haughey hderms@gmail.com Date: Tue Jan 15 19:35:50 2013 -0600
commit 8e8a7873b48e956e4642d31265dc767b5fafb096 Author: Dermot Haughey hderms@gmail.com Date: Tue Jan 15 19:25:42 2013 -0600