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

Adding attributes to wrapped element in XML collection #84

Closed
wants to merge 1 commit into from
Closed

Adding attributes to wrapped element in XML collection #84

wants to merge 1 commit into from

Conversation

navinpeiris
Copy link

We currently need to be able to add attributes to the element wrapping collections in XML, and from the code and the documentation I couldn't find an elegant way of doing this.

This will allow you to do the following:

collection :songs, :as => :song, :wrap => :songs, :wrap_attributes => {:foo => :bar}

which would generate the XML:

<?xml version="1.0"?>
<songs foo="bar">
  <song>
    <name>Thinning the Herd</name>
  </song>
</songs>

We currently need to be able to add attributes to the element wrapping collections in XML, and from the code and all the
documentation that I read, I couldn't find an elegant way of doing this.

This will allow you to do the following:

```ruby
collection :songs, :as => :song, :wrap => :songs, :wrap_attributes => {:foo => :bar}
```

which would generate the XML:

```xml
<?xml version="1.0"?>
<songs foo="bar">
  <song>
    <name>Thinning the Herd</name>
  </song>
</songs>
```
@apotonick
Copy link
Member

This is a great idea. However, if we allow rendering, we also have to take care of parsing that stuff back. I'd love to have a generic attributes mapping... like the one that's already in place, but working for child elements, too.

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.

None yet

2 participants