Simple starting point for Ember.js fiddles

by igalst

HTML

<script src="https://github.com/downloads/emberjs/ember.js/ember-0.9.4.js"></script>
<script type="text/x-handlebars">
    The President of the United States is {{MyApp.president.fullName}}, {{MyApp.president.age}} years old.
</script>

JavaScript

MyApp = Ember.Application.create({});

MyApp.president = Ember.Object.create({
    dob: new Date("04/08/1961"),
    firstName: "Barack",
    lastName: "Obama",

    age: function() {
        return (new Date()).getFullYear() - this.get('dob').getFullYear();

        // Call this flag to mark the function as a property
    }.property(),

    fullName: function() {
        return this.get('firstName') + ' ' + this.get('lastName');

        // Tell Ember that this computed property depends on firstName and lastName
    }.property('firstName', 'lastName')
});