Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Merge pull request #12 from stopcoder/master

Allow 'format' function to return an array to make a flat structure
  • Loading branch information...
commit 54aa5f30ea75fa7d0a9eb8ac13930894e23f7f8b 2 parents a5c08f6 + 084f0b7
@joelvh authored
Showing with 5 additions and 2 deletions.
  1. +1 −1 
  2. +4 −1 lib/
2 
@@ -114,7 +114,7 @@ The "choose" property defines an array of properties on the original JSON object
choose: ['SmallImage', 'MediumImage', 'LargeImage']
The "format" property defines a function that processes each of the values retrieved from the original JSON object
-and returns an object with "key" and "value" properties.
+and returns an object with "key" and "value" properties or an array which contains object(s) with "key" and "value" properties. If an array is returned, all entries in the array are added to the current context node in the new JSON.
This allows you to format the key and value however you wish.
(If a "key" or "value" property is not returned, the original value is used.)
The "node" parameter to the format function is the object or array in the original JSON that is being transformed.
5 lib/
@@ -109,7 +109,10 @@ class ObjectTemplate
updateContext: (context, node, value, key) =>
# format key and value
formatted = @config.applyFormatting node, value, key
- @aggregateValue context, formatted.key, formatted.value
+ if sysmo.isArray(formatted)
+ @aggregateValue context, item.key, item.value for item in formatted
+ else if formatted?
+ @aggregateValue context, formatted.key, formatted.value
aggregateValue: (context, key, value) =>
return context unless value?
Please sign in to comment.
Something went wrong with that request. Please try again.