Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit_nil_handling option to codebase #34

Merged
merged 2 commits into from
Feb 6, 2013

Conversation

hderms
Copy link
Contributor

@hderms hderms commented Jan 16, 2013

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

yields

<foo nil="true"/>

commit 430b9762c436f180db8686407b5002cb4f71e8b9
Author: Dermot Haughey hderms@gmail.com
Date: Tue Jan 15 19:36:00 2013 -0600

Add test

commit b9adb4d916ae1cf897ea2c1f39f5ad0c0def4460
Author: Dermot Haughey hderms@gmail.com
Date: Tue Jan 15 19:35:50 2013 -0600

Cleanup of code

commit 8e8a7873b48e956e4642d31265dc767b5fafb096
Author: Dermot Haughey hderms@gmail.com
Date: Tue Jan 15 19:25:42 2013 -0600

Make changes to add option

commit 430b9762c436f180db8686407b5002cb4f71e8b9
Author: Dermot Haughey <hderms@gmail.com>
Date:   Tue Jan 15 19:36:00 2013 -0600

    Add test

commit b9adb4d916ae1cf897ea2c1f39f5ad0c0def4460
Author: Dermot Haughey <hderms@gmail.com>
Date:   Tue Jan 15 19:35:50 2013 -0600

    Cleanup of code

commit 8e8a7873b48e956e4642d31265dc767b5fafb096
Author: Dermot Haughey <hderms@gmail.com>
Date:   Tue Jan 15 19:25:42 2013 -0600

    Make changes to add option
@jimweirich jimweirich merged commit 76d389d into jimweirich:master Feb 6, 2013
@jimweirich
Copy link
Owner

I'm not entirely convinced that this is a general purpose change, but I did go ahead and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants