Skip to content

Commit

Permalink
[fix] Make sure that we only do data lookups for attributes that actu…
Browse files Browse the repository at this point in the history
…ally are actually touched by the maps.
  • Loading branch information
3rd-Eden committed Aug 20, 2012
1 parent 28227c0 commit 4a87c15
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/plates.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
}

tagbody = tagbody.replace(this.attr, function(str, key, value, a) {
var newdata = fetch(data, mapping, value, key);
var newdata;

if (shouldSetAttribute && mapping.replace !== key || remove) {
return str;
Expand All @@ -250,7 +250,9 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
if (typeof mapping.replacePartial2 !== 'undefined') {
newdata = value.replace(mapping.replacePartial1, mapping.replacePartial2);
} else if (typeof mapping.replacePartial1 !== 'undefined' && mapping.dataKey) {
newdata = value.replace(mapping.replacePartial1, newdata);
newdata = value.replace(mapping.replacePartial1, fetch(data, mapping, value, key));
} else {
newdata = fetch(data, mapping, value, key);
}

return key + '="' + (newdata || '') + '"';
Expand Down Expand Up @@ -280,7 +282,7 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
buffer += tagbody + that.iterate(html, partial, components, tagname);
matchmode = true;
} else {
var v = newdata;
var v = newdata = fetch(data, mapping, value, key);
newdata = tagbody + newdata;

if (Array.isArray(v)) {
Expand Down

0 comments on commit 4a87c15

Please sign in to comment.