rotundasoftware/backbone.subviews — pull request #14 by markskipper (2014-02-27 17:17:30+00:00)
Title: Allow multiple subviews from the same subview creator function

I made the changes outlined below in order to support use of subviews to create a rudimentary collection view (yes,t I know about [Backbone.collectionView](https://github.com/rotundasoftware/backbone.collectionView), but that's not what I want). I hope these small changes enable use of this excellent little utility in additional ways. Thanks for making this available.

- Pass the placeholder div as a parameter to the subview creator function:

This allows the subview creator access to additional information about the subview it is about to create if that information is attached, e.g. as `data-` attributes on the placeholder element. The driving use case for this was selecting the model to use. The documentation example shows this use.

- In order to preserve caching behaviour we need distinct key values in the cache hash. I introduced support for an additional data attribute on the placeholder: `data-subview-id` which, if set, is used as the key in the hash. If it is not set, the value of `data-subview` is used, as before to preserve backward compatibility.

- Some tests

- Updated README.md to document new use cases

- Tried to bring debug version in line but haven't used or tested it so not confident about that.