Created
August 5, 2012 20:54
-
-
Save secunit64/3267096 to your computer and use it in GitHub Desktop.
Doing templates in meteor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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