You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As shown in this jsfiddle. I wanted to add a link to a list of users and found that if I try to use a Plates.Map to get the link right none of the other user data gets populated. However, I could make it work by extending the map to include the other data.
var collection = [
{id: 1, 'name': 'Louis CK'},
{id: 2, 'name': 'Andy Kindler'},
{id: 3, 'name': 'Greg Giraldo'}
];
var html = "<a href='/users/ID'><span class='name'>NAME</span></a></br>";
var map = Plates.Map().where('href').has(/ID/).insert('id');
var list1 = Plates.bind(html, collection, map); //Correctly creates the href but name stays NAME
var list2 = Plates.bind(html, collection); //Correctly populates name but of course the href is unchanged
// If I now extend the map to explicitly include name it will work as expected
map.class('name').to('name')
var list3 = Plates.bind(html, collection, map); //The new map correctly creates the link and populates the name
I am very surprised that I had to explicitly include what I expected to be the default instructions in order to get the name to populate correctly. Is this a bug, or am I just not understanding how plates should work by default?
Thanks
The text was updated successfully, but these errors were encountered:
But what i think you are saying is that Plates should have a set of default mappings; for instance, in your case, you want name (in the data) to automatically map to name (in the markup)? Weld did this to some extent, it attempted to map the key's to the attributes of anything that matched the id. Am I understanding you correctly?
As shown in this jsfiddle. I wanted to add a link to a list of users and found that if I try to use a Plates.Map to get the link right none of the other user data gets populated. However, I could make it work by extending the map to include the other data.
I am very surprised that I had to explicitly include what I expected to be the default instructions in order to get the name to populate correctly. Is this a bug, or am I just not understanding how plates should work by default?
Thanks
The text was updated successfully, but these errors were encountered: