Created
November 30, 2012 20:44
-
-
Save garth/4178463 to your computer and use it in GitHub Desktop.
Using Emberjs code on the server side with Nodejs
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
// enable emberjs globally | |
GLOBAL.Ember = { lookup: GLOBAL } | |
require('./vendor/ember/ember-runtime') | |
// define the client App object | |
GLOBAL.App = Ember.Application.create({}) | |
// include ember models | |
require('./public/js/login') |
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
// enable emberjs globally | |
GLOBAL.window = { console: console } | |
GLOBAL.Ember = {} | |
require('./vendor/ember/ember-runtime'); | |
delete GLOBAL.window | |
// define the client App object | |
GLOBAL.App = Ember.Application.create({}) | |
// include ember models | |
require('./public/js/login') |
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
App.Login = Ember.Object.extend({ | |
email: '', | |
password: '', | |
rememberUser: false, | |
status: function () { | |
if (this.get('email').length === 0) { | |
return 'Please enter an email address' | |
} | |
if (this.get('password').length === 0) { | |
return 'Please enter a password' | |
} | |
return '' | |
}.property('email', 'password'), | |
isValid: function () { | |
return this.get('status').length === 0 | |
}.property('status') | |
}) |
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
require('./login') | |
require('./loginView') | |
//create the controller | |
App.LoginController = Ember.ObjectController.extend({ | |
content: null | |
}) |
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
require('./login.handlebars') | |
App.LoginView = Ember.View.extend({ | |
templateName: 'login' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the blog post for more info http://garthw.wordpress.com/2012/11/30/emberjs-with-nodejs/