Giter VIP home page Giter VIP logo

node-ember's Introduction

Ember for Node

Ember.js is a framework for building ambitious client-side applications on the web. Now you can use the same Ember tools in node code and in node-based asset pipelines like Convoy.

Using This Package

Just add ember as a requirement to your package.json:

"dependencies": {
  ...
  "ember": "~0.9"
}

In your code, you can load the entire Ember stack by just requiring the package. This will add Ember to the global namespace in your application.

require('ember');

MyApp = Ember.Application.create({
  hi: function() { console.log("Hi! I'm an app!"); }
});

If you don't want to use the entire Ember stack, you can just require the specific module that you want. For example, a lot of server side code just needs States for statecharting:

require('ember/states');

MyState = Ember.State.create({
  
});

Using Ember with Convoy

Building an Ember application in the browser is very easy when using Convoy. Just require ember in your main application file.

// In some JS module included by convoy:
require('ember'); // <- convoy will automatically pull in all of Ember.

UserView = Ember.View.extend({
  template: Ember.Handlebars.compile('{{firstName}} {{lastName}}')
});

If you want to store your Handlebars templates in a separate file, Ember for Node has a HandlebarsCompiler that will precompile the templates for you. Here is an example Convoy pipeline configuration:

pipeline = convoy({
  'app.js': {
    packager: 'javascript',
    compilers: {
      '.hbr': require('ember/packager').HandlebarsCompiler
    }
  }
});

app = express.createServer();
app.use(pipeline.middleware());

This will now make .hbr files available as modules. In your app code, you can load the template via a normal require:

// user_view.js

require('ember/views');

UserView = Ember.View.extend({
  template: require('./user_template') // template in user_template.hbr
});

For a fully functioning example of an application, check out the examples folder.

node-ember's People

Contributors

wmill avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.