UNPKG

aglio-theme-olio

Version:

Default theme for the Aglio API Blueprint renderer

71 lines (67 loc) 1.93 kB
// Generated by CoffeeScript 1.9.3 (function() { var uniqueMembers, hasProp = {}.hasOwnProperty; uniqueMembers = function(content) { var i, key, known, results; known = []; i = content.length - 1; results = []; while (i >= 0) { if (content[i].element === 'member') { key = content[i].content.key.content; if (known.indexOf(key) !== -1) { content.splice(i, 1); continue; } known.push(key); } results.push(i--); } return results; }; module.exports = function(base, element) { var combined, item, j, key, len, ref, ref1, ref2, ref3, ref4, value; combined = JSON.parse(JSON.stringify(base)); if (element.meta) { if (combined.meta == null) { combined.meta = {}; } ref = element.meta; for (key in ref) { if (!hasProp.call(ref, key)) continue; value = ref[key]; combined.meta[key] = value; } } if (element.attributes) { if (combined.attributes == null) { combined.attributes = {}; } ref1 = element.attributes; for (key in ref1) { if (!hasProp.call(ref1, key)) continue; value = ref1[key]; combined.attributes[key] = value; } } if (element.content) { if (((ref2 = combined.content) != null ? ref2.push : void 0) || ((ref3 = element.content) != null ? ref3.push : void 0)) { if (combined.content == null) { combined.content = []; } ref4 = element.content; for (j = 0, len = ref4.length; j < len; j++) { item = ref4[j]; combined.content.push(item); } if (combined.content.length && combined.content[0].element === 'member') { uniqueMembers(combined.content); } } else { combine.content = element.content; } } return combined; }; }).call(this);