Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Readme formatting
  • Loading branch information
dansimpson committed May 24, 2011
1 parent 7676390 commit 6a2a24e
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions README.md
Expand Up @@ -13,70 +13,70 @@ to develop javascript heavy web applications without worrying about css and java


##Javascript satchels
val core = new Satchel(
name = "core",
root = "webapp/javascripts/vendor",
patterns = List(
"/jquery.js",
"/underscore.js",
"/backbone.js",
"/lib/**/*.js"
val core = new Satchel(
name = "core",
root = "webapp/javascripts/vendor",
patterns = List(
"/jquery.js",
"/underscore.js",
"/backbone.js",
"/lib/**/*.js"
)
)
)

// yields combined and processed results
core.processed

// yields combined and processed results
core.processed

The above code registers a satchel by the name of core, and includes
jquery, underscore, backbone, and all js files in the lib sub-directory.

##Production/Development mode

// enable dev mode
// no caching, no compression
Satchel.devmode = true

// disable dev mode
// compressed and cached
Satchel.devmode = false
// enable dev mode
// no caching, no compression
Satchel.devmode = true
// disable dev mode
// compressed and cached
Satchel.devmode = false


##Javascript template satchels
val templates = new Satchel(
name = "templates",
root = "webapp/javascripts/templates",
mime = "jst",
patterns = List(
"/**/*.jst",
"/**/*.mustache"
val templates = new Satchel(
name = "templates",
root = "webapp/javascripts/templates",
mime = "jst",
patterns = List(
"/**/*.jst",
"/**/*.mustache"
)
)
)

The above will generate a wrapped JS object for each found template.
If for example, a file called index.jst existed in the root directory,
we would access the template in javascript via:

var index = JST["/index.jst"]

// or a nested mustache template
var other = JST["/subdirectory/other.mustache"]
var index = JST["/index.jst"]
// or a nested mustache template
var other = JST["/subdirectory/other.mustache"]

##CoffeeScript satchels
val coffee = new Satchel(
name = "coffee",
root = "webapp/coffeescripts",
mime = "coffee",
patterns = List(
"/**/*.coffee"
val coffee = new Satchel(
name = "coffee",
root = "webapp/coffeescripts",
mime = "coffee",
patterns = List(
"/**/*.coffee"
)
)
)

Note: coffee-script.js must exist in your classpath, you can get it here: https://github.com/jashkenas/coffee-script/tree/master/extras

##Running with Scalatra
Simply add the servlet to your servlet container.

context.addServlet(new ServletHolder(new SatchelServlet()), "/bundles/*")
context.addServlet(new ServletHolder(new SatchelServlet()), "/bundles/*")

Now you can access your satchels via /bundles/core.js or /bundles/coffee.coffee

0 comments on commit 6a2a24e

Please sign in to comment.