derickbailey/backbone.modelbinding — pull request #61 by paulj (2012-02-02 02:48:45+00:00)
Title: Don't bind an element when the convention references a non-present attribute

In my application, I'm databinding the same DOM tree twice with two different views - I've got a main view, then a table of children that are each bound to their own view.

To allow for repetition, I'm changing the form element convention to use a `data-key` element on the parent, and `data-row-key` on the children. This works fine for binding the children, however when I bind the parent, it binds all of the fields in each child to the `undefined` key of the parent model (since the children don't define the `data-key` attribute).

My patch prevents binding of a field if the resolution of `attribute_name` doesn't turn up anything. It is really only the insertion of the `if()`, but that of course causes a bunch of changes in the indentation of the contained lines.