batman.js template
by johnthethird
HTML
<script src="https://github.com/jashkenas/coffee-script/raw/master/extras/coffee-script.js"></script>
<script src="http://github.com/Shopify/batman/raw/master/lib/es5-shim.js"></script>
<script src="http://github.com/Shopify/batman/raw/master/lib/batman.js"></script>
<script src="http://github.com/Shopify/batman/raw/master/lib/batman.jquery.js"></script>
<link rel="stylesheet" href="http://batmanjs.org/examples/resources/reset.css">
<div id="container">
<input class="title" type="text" data-bind="person.firstName" />
<div data-bind="person.firstName"></div>
<div data-context="person">
<div data-view="TestView">
</div>
</div>
</div>
<!-- This enables us to run coffeescript below. --->
<script>(function(){var s="script",n='\n',d=document,b=d.getElementsByTagName(s);b=b[b.length-2].innerHTML.split(n); d.write('<'+s+' type="text/coffeescript">'+b.slice(2,b.length-2).join(n)+'</'+s+'>');})()</script>
CSS
body {
background-color: #f0f0f0;
}
#container {
display: block;
width: 400px;
margin: 0 auto;
margin-top: 30px;
}
h2 {
clear: both;
}
CoffeeScript
# batman.js jsfiddle Template ©2011 CJ Lazell
class Hello extends Batman.App
class Person extends Batman.Model
firstName: 'Test'
@accessor 'fullName', -> "#{@get('firstName') or ''} #{@get('lastName') or ''}"
@accessor 'hasName', -> @get('firstName') or @get('lastName')
Hello.person = new Person()
Hello.run()
class Hello.TestView extends Batman.View
html: "<input data-bind='firstName' />"
render: ->
@node = $(@get('node'))
super