// `examples` is an object, mapping language->example module.exports.code = examples => { return `
${ Object.keys(examples).sort(langPrioritySort).map(lang => `
${lang}
`).join('') }
${ Object.keys(examples).sort(langPrioritySort).map(lang => `
${cleanupCode(examples[lang])}
`).join('') }
` } // enforce an order to the language tabs function langPrioritySort (a, b) { if (b == 'js' && a != 'js') return 1 return -1 } // do some cleanup on the code function cleanupCode (str) { return str.trim() }