Code Monkey home page Code Monkey logo

ember-express-coffee's Introduction

Ember-express-coffee

I'm currently experimenting with emberjs and coffee-script. So I was searching to get started using those two. Of course I stumbled across yeoman/generator-ember which seems to have coffee-script support. But this support doesn't work that well since it's hard to use it with coffee-script's sourceMap feature (see this) which is important for me. Additionally it feels like the folks from yeoman/generator-ember are more focused on getting the js thing to go which is ok. But since I want to try coffee-script I want, for example, the Gruntfile to be in coffee-script, too. So I took the time to learn about the grunt-plugins used in yeoman/generator-ember and combined them in this project without the bloat I don't need. One time this will maybe become a yeoman generator. Any contributions or tips are welcome.

Happy hacking!

Getting started

$ npm install
$ bower install
$ grunt server

This launches a connect instance and mounts the application. So all you have to do is open http://localhost:3000 in your browser and start coding. After each change the page is reloaded automatically due to livereload.

Source structure

.
|-- bower.json
|-- client
|   |-- coffee
|   |   |-- app.coffee
|   |   |-- models
|   |   |   `-- color.coffee
|   |   |-- routes
|   |   |   `-- index.coffee
|   |   |-- runner.coffee
|   |   `-- tests.coffee
|   |-- css
|   |   |-- runner.css
|   |   `-- style.css
|   |-- index.jade
|   `-- templates
|       |-- application.hbs
|       `-- index.hbs
|-- Gruntfile.coffee
|-- package.json
|-- public
|-- README.md
|-- src
|   |-- app.coffee
|   `-- server.coffee
`-- views

This is the source structure layed out. client/ includes everything which has to do with the client: stylesheets, coffee-scripts and the templates used in the ember application. The server sources are located in src/. Everytime you add something (stylesheet, coffee-script etc.) to your application you have to make sure to link it in your index.jade file which is the entrypoint of the application and looks like this:

doctype html
html
  head
    meta(charset='utf-8')
    title Ember Starter Kit
    if env == 'development'
      link(rel='stylesheet'
           href='bower_components/bootstrap/dist/css/bootstrap.css')
    else
      link(rel='stylesheet'
           href='bower_components/bootstrap/dist/css/bootstrap.min.css')
    // build:css css/main.css
    link(rel='stylesheet' href='css/style.css')
    // endbuild
  body
    // build:js js/components.js
    script(src='bower_components/jquery/jquery.js')
    script(src='bower_components/handlebars/handlebars.js')
    script(src='bower_components/bootstrap/dist/js/bootstrap.js')
    // endbuild
    if env == 'development'
      script(src='bower_components/ember/ember.js')
      script(src='bower_components/ember-data/ember-data.js')
    else
      script(src='bower_components/ember/ember.min.js')
      script(src='bower_components/ember-data/ember-data.min.js')
    // build:js js/main.js
    script(src='js/templates.js')
    script(src='js/app.js')
    script(src='js/models/color.js')
    script(src='js/routes/index.js')
    // endbuild
    if env == 'development'
      // to activate the test runner, add the "?test" query string parameter
      script(src='js/runner.js')

For example to add a new model called Customer you would write your coffee-script and add the corresponding javascript file to the js block like this:

    // build:js js/main.js
    script(src='js/templates.js')
    script(src='js/app.js')
    script(src='js/models/color.js')

    // The new model
    script(src='js/models/customer.js')
    script(src='js/routes/index.js')
    // endbuild

Deploy

To run your application in production mode use the following:

$ grunt build
$ NODE_ENV=production npm start

Contribute

This should be enough to get started. Feel free to tweak and refine the Grunfile.coffee or anything else in this scaffold and then let me know about it via a pull request or an issue.

ember-express-coffee's People

Watchers

Dominik Burgdörfer avatar James Cloos 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.