No commit activity in last 3 years
No release in over 3 years
Adds AMD support and Almond to the asset pipeline
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 2.9
 Project Readme

This library adds AMD (via Almond) support to Sprockets.

What is AMD?

The AMD format is a way of encapsulating JavaScript libraries, ensuring they have to explicitly define their dependencies.

This library

This library adds AMD support to Sprockets, so it can wrap up JavaScript files as modules, and serve them appropriately. This is done by using define_module to declare a new module. You should put your files under app/assets/javascripts/modules/.

define_module(["backbone"], function(BB) {});

Sprockets will then postprocess your JS and insert the correct logical asset name as module name.

define("tickets/controller", ["backbone"], function(BB) {});

This is just syntactic sugar on top of the goodness that AMD already provides through Almond.

Usage

  1. Add gem 'sprockets-almond' to your Gemfile
  2. Add //= require sprockets/almond to your application.js
  3. Require all the modules, e.g.: //= require_tree ./models