Permalink
Browse files

[fix] Make sure that we only do data lookups for attributes that actu…

…ally are actually touched by the maps.
  • Loading branch information...
3rd-Eden committed Aug 20, 2012
1 parent 28227c0 commit 4a87c15fc2bf2a9e39d4118ec2f8e011ff789104
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/plates.js
View
@@ -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;
@@ -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 || '') + '"';
@@ -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)) {

0 comments on commit 4a87c15

Please sign in to comment.