Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[minor] Changed the .to(fucntion() {}) arguements to include tagbody

  • Loading branch information...
commit 5f39214bf805e6d36d698a38c217ec30dbefa759 1 parent 4a87c15
@3rd-Eden 3rd-Eden authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/plates.js
View
15 lib/plates.js
@@ -32,17 +32,18 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
// ### function fetch(data, mapping, value, key)
// #### @data {Object} the data that we need to fetch a value from
// #### @mapping {Object} The iterated mapping step
+ // #### @tagbody {String} the tagbody we operated against
// #### @key {String} optional key if the mapping doesn't have a dataKey
// Fetches the correct piece of data
//
- function fetch(data, mapping, value, key) {
+ function fetch(data, mapping, value, tagbody, key) {
key = mapping.dataKey || key;
//
// Check if we have data manipulation or filtering function.
//
if (mapping.dataKey && typeof mapping.dataKey === 'function') {
- return mapping.dataKey(data, value, key);
+ return mapping.dataKey(data, value || '', tagbody || '', key);
}
return data[key];
@@ -232,7 +233,7 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
// check if we are targetting a element only or attributes
//
if ('tag' in mapping && !this.attr.test(tagbody) && mapping.tag === tagname) {
- tagbody = tagbody + fetch(data, mapping, '');
+ tagbody = tagbody + fetch(data, mapping, '', tagbody);
continue;
}
@@ -250,9 +251,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, fetch(data, mapping, value, key));
+ newdata = value.replace(mapping.replacePartial1, fetch(data, mapping, value, tagbody, key));
} else {
- newdata = fetch(data, mapping, value, key);
+ newdata = fetch(data, mapping, value, tagbody, key);
}
return key + '="' + (newdata || '') + '"';
@@ -282,7 +283,7 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
buffer += tagbody + that.iterate(html, partial, components, tagname);
matchmode = true;
} else {
- var v = newdata = fetch(data, mapping, value, key);
+ var v = newdata = fetch(data, mapping, value, tagbody, key);
newdata = tagbody + newdata;
if (Array.isArray(v)) {
@@ -324,7 +325,7 @@ var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefi
' ',
mapping.replace,
'="',
- fetch(data, mapping, ''),
+ fetch(data, mapping),
'"',
close
].join('');
Please sign in to comment.
Something went wrong with that request. Please try again.