diff --git a/lib/plates.js b/lib/plates.js index 85b9723..7d4d0bc 100644 --- a/lib/plates.js +++ b/lib/plates.js @@ -360,12 +360,12 @@ function matchClosing(input, tagname, html) { newdata = tagbody + newdata; if (Array.isArray(v)) { - newdata = that.iterate(html, v, components, tagname, value, map); + newdata = that.iterate(html, v, components, tagname, mapping.dataKey, map); // If the item is an array, then we need to tell // Plates that we're dealing with nests that.nest.push(tagname); } else if (typeof v === 'object') { - newdata = tagbody + that.iterate(html, v, components, tagname, value, map); + newdata = tagbody + that.iterate(html, v, components, tagname, null, map); } buffer += newdata || ''; diff --git a/test/api-test.js b/test/api-test.js index 5d2630e..9a8cd03 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -504,6 +504,31 @@ vows.describe('merge data into markup').addBatch({ return common.createTest('test-41', map); }() + ), + + '(42) Should bind according to the mapping for an array': ( + + function() { + var map = Plates.Map(); + + map.class("names").use("names"); + map.class("last").use("lastname"); + + return common.createTest('test-42', map); + }() + ), + + '(43) Should bind to according to the mapping for an object': ( + + function() { + var map = Plates.Map(); + + map.class("name").use("fullname"); + map.class("first").use("firstname"); + map.class("last").use("lastname"); + + return common.createTest('test-43', map); + }() ) } diff --git a/test/fixtures/test-42.html b/test/fixtures/test-42.html new file mode 100755 index 0000000..4d1a3dd --- /dev/null +++ b/test/fixtures/test-42.html @@ -0,0 +1,5 @@ +