Skip to content

Instantly share code, notes, and snippets.

@garrilla
Created October 2, 2014 10:32
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 garrilla/69b4fcd25e37b4362223 to your computer and use it in GitHub Desktop.
Save garrilla/69b4fcd25e37b4362223 to your computer and use it in GitHub Desktop.
helper and invocation METEOR@0.9.4-pre.6
/* CSS declarations go here */
<head>
<title>9.4.0pre2rc6</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
{{> invoker}}
</body>
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
<template name="invoker">
<p>{{theOldWay}}</p>
</template>
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault("counter", 0);
Template.hello.helpers({
counter: function () {
return Session.get("counter");
},
possNewMethod: function(){
console.log('we should never get here, this approach should generate an error');
}
});
Template.hello.events({
'click button': function () {
// increment the counter when button is clicked
Session.set("counter", Session.get("counter") + 1);
}
});
Template.hello.rendered=function(){
console.log(Meteor.release)
Template.hello.utils.someFun();
console.log(Template.hello.utils.someFun())
console.log(Template.hello.theOldWay());
console.log(Template.invoker.theOldWay());
/* the following, if uncommented, will produce
TypeError: undefined is not a function
*/
//Template.hello.possNewMethod();
//Template.hello.helpers.possNewMethod();
}
Template.hello.utils = {
someFun: function(){
console.log('Look Mummy, no deprecation message...');
return 'print some return text'
}
}
Template.hello.theOldWay = function(){
console.log('Look Mummy, no deprecation message...');
return 'theOldWay on the hello Template'
}
Template.invoker.theOldWay = function(){
console.log('Oh No, Daddy, I got that deprecation message...');
return 'theOldWay on the invoker Template'
}
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment