Created
May 12, 2015 23:14
-
-
Save Michael-Lazell/f773026ca90d0e95bf4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the content with all of the reference related content | |
* @param {string} the content path or id. | |
* @param {object} the name of the reference and the new name that the actual content objects will have. | |
* @return {object} the content with all of its reference content objects. | |
*/ | |
exports.content.getWithRefs = function(key, refs) { | |
/*Example object structure. Note this only works for single contents. | |
{ | |
'image' : 'imageContent', | |
'department' : 'departmentContent' | |
}*/ | |
if(exports.content.exists(key)){ | |
var content = exports.content.get(key); | |
var data = content.data; | |
var ref; | |
for ( ref in refs ) { | |
if(refs.hasOwnProperty(ref)) { | |
data[refs[ref]] = exports.content.get(data[ref]); | |
} | |
} | |
return content; | |
} | |
return null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment