0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Serves Ember Handlebars pages.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

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.

Installation

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'

Setup

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
  }
end

API reference

ember.templates

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

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

URI

a string defining where the templates will be served.

PATH

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

Options

:relative_to

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.

ember.template_name_style

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

# Usage:
ember {
  template_name_style :basename
}

Valid options include:

:path

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

:basename

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.