Skip to content

Instantly share code, notes, and snippets.

@garrilla
Created September 26, 2015 12:27
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/8d91694c87e945e092e4 to your computer and use it in GitHub Desktop.
Save garrilla/8d91694c87e945e092e4 to your computer and use it in GitHub Desktop.
/* CSS declarations go here */
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({
counter: function () {
return Session.get('counter');
}
});
Template.hello.events({
'click button': function () {
// increment the counter when button is clicked
Session.set('counter', Session.get('counter') + 1);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
<head>
<title>newapp</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment