I have a collection, Ages, which only holds one key: ages.
In it I store an array of strings like so:
['51', '24', '21', '19', '15']
I struggled a bit with how to iterate over it in the template but this is what I found worked. First the HTML:
<template name="ageFilter">
{{#each age}}
<li>
{{this}}
</li>
{{/each}}
</template>
And the helper:
Template.ageFilter.helpers({
age: function() {
return Ages.findOne().ages
}
})
This is a rather ugly solution that rests on my having only one object in my database (since I use findOne() but it's not a big problem, and it works. The template iterates over the array and outputs it.
There's only one problem: the browser console throws an error!
Exception in template helper: TypeError: Cannot read property 'ages' of undefined
Why is this and how can I get rid of it?