We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When a collection is empty, there is no need to render.
Instead, apply render_nil: true behavior when specified. Right now render_nil only works on elements not on collections.
render_nil: true
render_nil
The text was updated successfully, but these errors were encountered:
@ronaldtse I tried to run the below code and it does not render anything if the collection is empty.
require 'shale' require 'shale/adapter/nokogiri' Shale.xml_adapter = Shale::Adapter::Nokogiri class Address < Shale::Mapper attribute :city, Shale::Type::String attribute :street, Shale::Type::String attribute :zip, Shale::Type::String, collection: true xml do root "address" map_element "city", to: :city map_element "street", to: :street map_element "zip", to: :zip end end address = Address.from_xml(<<~DATA) <address> <city>London</city> <street>Oxford Street</street> </address> DATA puts address.to_xml(pretty: true)
the above code outputs the following XML
<address> <city>London</city> <street>Oxford Street</street> </address>
Do you mean something else here?
Sorry, something went wrong.
No branches or pull requests
When a collection is empty, there is no need to render.
Instead, apply
render_nil: true
behavior when specified. Right nowrender_nil
only works on elements not on collections.The text was updated successfully, but these errors were encountered: