/** Because Handlebars sucks and won't let you iterate with @index * Use this lookup helper to do things with the automatic @index var inside loops * * Usage example: (Get the item at @index each iteration through foo) * {{#each foo}} *
{{someProp}}
*
{{lookup ../dailyStat @index}}
* {{/each}} * * Block usage example: (get the item at @index in monthlyUniqueCustomers and then use its subcomponents * {{#lookup monthlyUniqueCustomers @index}} *
Count: {{count}}
*
Growth: {{growth}}
* {{/lookup}} * @param {obj} object (or array) whose field is accessed in a .hbs file * @param {key} key (or index) designating which field of the object to access * @param {options} [options] - allows the helper to be used as a block helper * @returns {string} The text to be generated by handlebars */ Handlebars.registerHelper('lookup', function(obj, key, options) { if (options) return options.fn(obj[key]); else return obj[key]; });