Skip to content

Instantly share code, notes, and snippets.

@tilleps
Created June 27, 2013 21:49
Show Gist options
  • Save tilleps/5880718 to your computer and use it in GitHub Desktop.
Save tilleps/5880718 to your computer and use it in GitHub Desktop.
//
// HTML
//
<html>
<head></head>
<body class="loading"></body>
</html>
//
// Template (layout.hbr)
//
<div>
Layout #1
<div>Hello {{person}}!</div>
<div>
<div>Count: <span class="count">{{count}}</span></div>
<button class="increment">increment</button>
<button class="decrement">decrement</button>
</div>
</div>
//
// app.js
//
var theCount = can.compute(0);
var App = can.Control({
init: function(element, options) {
var self = this;
self.element.removeClass('loading');
self.element.html('layout.hbr', {
person: "world",
count: can.compute(theCount)
});
},
'button.increment click': function() {
theCount(theCount()+1);
},
'button.decrement click': function() {
theCount(theCount()-1);
},
});
new App('body', {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment