Giter Site home page Giter Site logo

emberman's Introduction

Emberman Gem Version

Middleman + Ember, sitting in a tree...

Emberwhat?

Emberman is a simple extension which allows you to easily serve an Ember app from your Middleman static site. It works by wrapping other excellent gems, along with some basic configuration, to get you quickly started.

Features

Installation

Add this line to your Middleman application's Gemfile:

# Gemfile

gem 'emberman', '~> 0.1.3'

Then run:

$ bundle

Activate the extension from your Middleman site's config.rb file:

# config.rb

activate :emberman

Start the Middleman server.

$ middleman

Other requirements

For now, Ember's [and Emberman's] only other requirement is for jQuery to be present. This may change soon ;)

Configuration

Emberman expects you to follow certain conventions in order to work its magic. However, some basic customization options are allowed:

Default directory structure

Emberman, by default, expects your Ember app's main JavaScript file to live in your Middleman site's JavaScript assets directory (source/javascripts).

Ember assets (models, controllers, views, routes, etc.) should be placed in an ember directory, nested under your JavaScript assets directory. The Handlebars templates directory must live inside the ember directory, and be named templates. These templates should use the standard .hbs or .handlebars file extensions. E.g.:

my-middleman-site/
  |
  + source/
  |    |
  |    + javascripts/ <- Middleman's default JavaScript assets directory
  |         |
  |         + app.js  <- Main Ember app file, any name works
  |         |
  |         + ember/  <- Ember assets directory
  |              |
  |              + templates/
  |              |    |
  |              |    + index.hbs
  |              |    + ...
  |              |
  |              + routes/...
  |              + models/...
  |              + controllers/...
  |              + views/...
  |              + components/...
  |              + adapters/...
  |              + ...
  |         
  + config.rb
  + Gemfile
  + ...

Custom directory names

Middleman allows you to customize the JavaScript assets directory by setting the :js_dir property in your config.rb.

Likewise, you can set a custom name for your Ember assets directory by passing an :app_dir option when you activate the extension in your config.rb. The Ember assets directory will always be relative to Middleman's JavaScript assets directory. E.g.:

# config.rb

set :js_dir, 'assets/js' # Set Middleman's JavaScript directory
activate :emberman, app_dir: 'my-ember-app' # Ember assets dir name
my-middleman-site/
  |
  + source/
  |    |
  |    + assets/
  |    |    |
  |    |    + js/                 <- JavaScript assets directory
  |    |       |
  |    |       + my-ember-app.js  <- Main Ember app file, any name works
  |    |       |
  |    |       + my-ember-app/    <- Ember assets directory
  |    |            |
  |    |            + templates/
  |    |            |    |
  |    |            |    + index.hbs
  |    |            |    + ...
  |    |            |
  |    |            + routes/...
  |    |            + models/...
  |    |            + controllers/...
  |    |            + views/...
  |    |            + components/...
  |    |            + adapters/...
  |    |            + ...
  |         
  + config.rb
  + Gemfile
  + ...

Including the assets

Once you've setup the directories/files following the aforementioned conventions, you can include the assets in your main Ember app's JS file through Middleman's Asset Pipeline. Note that only the Runtime version of Handlebars is necessary, since the templates are pre-compiled. E.g.:

//= require jquery
//= require handlebars.runtime
//= require ember
//= require ember-data
//= require_self
//= require ./ember/router
//= require_tree ./ember/templates
//= require_tree ./ember/adapters
//= require_tree ./ember/components
//= require_tree ./ember/controllers
//= require_tree ./ember/models
//= require_tree ./ember/routes
//= require_tree ./ember/views

Using other versions of Ember, Ember Data or Handlebars

If you'd prefer to use different versions of Ember, Ember Data or Handlebars, add their corresponding source gems to your Gemfile:

# Gemfile

gem 'ember-source',       '1.8.1'
gem 'ember-data-source',  '0.14'
gem 'handlebars-source',  '1.3.0'
gem 'emberman',           '~> 0.1.3'

Contributing

See CONTRIBUTING.

License

See LICENSE.

Thanks

emberman's People

Contributors

minusfive avatar

Watchers

Carsten Nielsen avatar Justin Giancola avatar  avatar Benjamin Moss avatar  avatar 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.