A framework for creating ambitious web applications.Ember PR Dept.
Rails turned many of us from dabblers into developers and Ember has that same feel of rightness for me that Rails did in 2004.- Trek Glowacki / @trek
<h1>Comments</h1>
<div id="comments">
{{#each comments}}
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
<div>{{body}}</div>
{{/each}}
</div>
App.Person = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
birthday: DS.attr('date'),
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
match 'modules/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'app.js'
end
match 'css/**/*.css' do
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat ['bootstrap.css', 'main.css'], 'app.css'
end
MyApp.president = Ember.Object.create({
name: "Barack Obama"
});
MyApp.country = Ember.Object.create({
// Ending a property with 'Binding' tells Ember to
// create a binding to the presidentName property.
presidentNameBinding: 'MyApp.president.name'
});
// Later, after Ember has resolved bindings...
MyApp.country.get('presidentName');
// "Barack Obama"
Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: function() {
var firstName = this.get('firstName');
var lastName = this.get('lastName');
return firstName + ' ' + lastName;
}.property('firstName', 'lastName')
});
var himself = Person.create({
firstName: "Donald",
lastName: "Duck"
});
himself.get('fullName') // "Donald Trump"
controllers
helpers
models
routes
templates
views
App.Router = Ember.Router.extend({
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
redirectsTo: 'posts'
}),
posts: Ember.Route.extend({
route: '/posts',
connectOutlets: function(router) {
router.get('applicationController').connectOutlet('posts', App.Post.find());
}
}),
post: Ember.Route.extend({
route: '/posts/:post_id'
})
})
});
App.Models.Task = DS.Model.extend({
// Properties:
//
title: DS.attr('string'),
completed: DS.attr('boolean'),
created_at: DS.attr('string'),
// Observe changes and persist them in elasticsearch
//
changed: function() {
App.store.commit()
}.observes('completed')
});
Slides: http://talks.cyt.ch/talk-emberjs