Tuesday, 27 August 2013

How does Meteor Coffeescript namespacing work?

How does Meteor Coffeescript namespacing work?

My collection Groups wasn't being recognized in my template function. I
thought it might be due to the file-scope variables in CS. However, when I
added the JS file as recommended in http://docs.meteor.com/#coffeescript ,
the error was not resolved.
#lib/scope.js
var Groups;
#collections/groups.coffee
Groups = new Meteor.Collection 'groups'
#client/views/index.html
<template name="test">

<br>

{{/each}}
</template>
#client/views/index.coffee
Template.test.all_groups = ->
Groups.find({})
The error, shown in the browser console, is on the Groups.find({}) call:
Uncaught ReferenceError: Groups is not defined

No comments:

Post a Comment