Helpers for serving an Ember.js app from Sinatra.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Sinatra Ember

Helpers for serving an Ember.js app from Sinatra.

  • Pre-compile handlebars templates from separate view files rather than littering them throughout your html.


You can install Sinatra Ember as a Ruby gem. You can install it via gem install.

$ gem install sinatra-ember

Bundler users

If you use Bundler, add it to your Gemfile.

gem 'sinatra-ember', :require => 'sinatra/ember'


Install the plugin and add some options.

require 'sinatra/ember'

class App < Sinatra::Base
  register Sinatra::Ember
  ember {
    templates '/js/templates.js', ['app/templates/**/*.hbs'], :relative_to => 'app/templates'

    # optional; defaults to :path
    template_name_style :path

API reference


Combines templates in the given paths into a single asset of those templates in javascript form.

# Usage:
ember {
  templates 'URI', [PATH, PATH, ...], OPTIONS_HASH


a string defining where the templates will be served.


a string or glob pattern describing a file or files that should be included



a string describing a path relative to the Sinatra root from which the template names should be made relative to when using the :path template name style. For example, if :relative_to is app/templates and the PATH app/templates/views/post.hbs will be named views/post.


Defines the style by which template names will be derived from the paths.

# Usage:
ember {
  template_name_style :basename

Valid options include:


the template will be named as a relative path to the template file


the template will be named as the basename of the template file

Sinatra AssetPack

If you're using the sinatra-assetpack gem, add your served templates to a package.