0.0
No commit activity in last 3 years
No release in over 3 years
Simple preprocessor for JavaScript files for adding AMD style definitions
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

sprockets-amd

Simple preprocessor for JavaScript files for adding AMD style definitions

There are three easy steps to start using it:

1. Configure prefix

Sometimes you want to add namespace for your coffee class names:

SprocketsAmd.configure do |config|
  config[:prefixes] = ["App"]
end

Now you can use AMD.require.App.Testclass and AMD.module.App.Testclass

2. Rename your file

Just add .amd extension to your js file. For example, test.js.coffee should become test.js.amd.coffee.

3. Add some code

First, choose the module name:

class Test
  someAction: ->

should become

class AMD.module.Test
  someAction: ->

Second, prefix your dependencies:

class Test
  someAction: ->
    new machina.Fsm

should become

class Test
  someAction: ->
    new AMD.require.machina.Fsm

You're good to go!

Now we will do the rest to make the file AMD-compatible.