flatiron/plates — Issue #13: Please help me simplify this use case.
Author: mwawrusch
Created: 2011-11-18 07:45:40+00:00
State: open

Here is an example from my code which works with the current version of plates. I am not happy with the complexity. How can this be simplified

A couple of notes. I tried to map the creator object using . notation, but that did not work, so I had to resort to create a custom view object to avoid polluting the data object.
I tried to use class names like data-bind-name and map them to name, that would be a less intrusive version than what we have now. The reason I cannot use a 1 to 1 match (class name to name data property) is because it gets unmaintainable and undebuggable given the amount of css present. With a common name prefix I can do a text search over data-bind and find all the instances.

Another problem was the a tag that contains two elements to be mapped, hence the data-bind-href and data-bind.

I am reallz open for any suggestion how this could be simplified. In a perfect world I want to have a clean html and the least amount of code.

```javascript
{
"scottyId" : "23423445546456",
"name" : "Frank",
"creator" : {
"avatarUrl30" : "http:// ...."
}
}
```

```html

```

```javascript
_render_scotty_ref: function(scottyRef) {
var html, mappedData, mapping;
html = '... see above ...';
mappedData = {
name: scottyRef.name,
creator_avatarUrl30: scottyRef.creator.avatarUrl30,
linkToScotty: window.routingController.getDesignScottyPath(scottyRef.scottyId)
};
mapping = {
'name': ['data-bind'],
'creator_avatarUrl30': ['data-bind', 'src'],
'linkToScotty': ['data-bind-href', 'href']
};
return Plates.bind(window.platesController.bind("browse_scotties_editor_template_scotty_ref", mappedData, mapping));
}
```