Skip to content

Instantly share code, notes, and snippets.

@bruceharris
Last active December 21, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruceharris/6279580 to your computer and use it in GitHub Desktop.
Save bruceharris/6279580 to your computer and use it in GitHub Desktop.
Does Meteor namespacing work as documented?

Meteor namespacing, specifically package scope variables, don't seem to work as described in the namespacing section of the docs.

From what I can tell, when the var keyword is omitted, actual globals are created. (I'm running 0.6.5)

To run this:

$ meteor create globalcheck

then copy these files into globalcheck (overwriting the default files)

<head>
<title>globalcheck</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
{{greeting}}
</template>
foo = "truly global, not package scope";
if (Meteor.isClient) {
Template.hello.greeting = function () {
// window.foo is truly global, not package scope
return "window.foo is " + window.foo;
};
}
if (Meteor.isServer) {
Meteor.startup(function () {
// global.foo is truly global, not package scope
console.log("global.foo is " + global.foo);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment