Skip to content

Instantly share code, notes, and snippets.

@secunit64
Created August 5, 2012 20:54
Show Gist options
  • Select an option

  • Save secunit64/3267096 to your computer and use it in GitHub Desktop.

Select an option

Save secunit64/3267096 to your computer and use it in GitHub Desktop.
Doing templates in meteor
if (Meteor.is_client) {
Meteor.startup(function(){
Session.set('first', 1);
Session.set('last', 'Srinivasan');
var fragment = Meteor.ui.render(function (){
return Template.hello({
first: Session.get('first'),
last: Session.get('last')
});
});
document.body.appendChild(fragment);
//Instead of the above, you can also use the following to get the same effect.
//Template.hello.first = function() {return Session.get('first');};
//Template.hello.last = function() {return Session.get('last');};
var indx=0;
Meteor.setInterval(function(){Session.set('first',indx+=10)},1000);
});
<head>
<title>karya</title>
</head>
<body>
{{> hello}} //needed only if not using Meteor.ui.render(..)
</body>
<template name='hello'>
<div class='greeting'>
Hello {{first}} {{last}} !
</div>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment