Skip to content

Commit

Permalink
implement suggestions from @jrburke
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Williams committed Sep 11, 2011
1 parent adf2331 commit 31c1cea
Show file tree
Hide file tree
Showing 16 changed files with 10,600 additions and 7 deletions.
17 changes: 11 additions & 6 deletions Readme.md
@@ -1,6 +1,6 @@
# require-jade

A [Jade](http://jade-lang.org/) loader plugin for [RequireJS](http://requirejs.org).
A [Jade](http://jade-lang.com/) loader plugin for [RequireJS](http://requirejs.org).

It is known to work with RequireJS 0.26.0+.

Expand All @@ -11,17 +11,22 @@ serve your .jade files.

## Usage

1) Download the latest release version of jade.js. It includes Jade (0.15.4).

2) Reference Jade files via the jade! plugin name:
Reference Jade files via the jade! plugin name:

require(['jade!userview'], function (userView) {
$('.user').html(userView());
$('.user').html(userView(locals));
});

They will be returned as a Jade template function that accepts locals as the first arg.

# Optimizing

jade.js includes optimizer instructions. To use the activate the instructions just include:
When you are ready to deploy your application and want to compile your JS into a single file
you can make used of the requireJS optimizer. Jade.js includes optimizer instructions that will
precompile the templates and remove the Jade compiler from the compiled source. Only do this
if you are not going to be dynamically including more Jade templates.

To use the activate the instructions just include:

pragmasOnSave: {
excludeJade : true
Expand Down
1 change: 1 addition & 0 deletions demo-build/build.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions demo-build/build.sh
@@ -0,0 +1,4 @@
#!/bin/sh

rm -rf ../demo-build
node ../tools/r.js -o build.js
6 changes: 6 additions & 0 deletions demo-build/build.txt
@@ -0,0 +1,6 @@

lib/main.js
----------------
jade!views/welcome
lib/../../jade.js
lib/main.js
10 changes: 10 additions & 0 deletions demo-build/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>CoffeeScript Loader Plugin Demo</title>
<script data-main="lib/main" src="lib/require.js"></script>
</head>
<body>
<div id="main"></div>
</body>
</html>
1 change: 1 addition & 0 deletions demo-build/lib/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo-build/lib/require.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo-build/lib/views/welcome.jade
@@ -0,0 +1 @@
h1 Jade Templates for RequireJS
23 changes: 23 additions & 0 deletions demo/build.js
@@ -0,0 +1,23 @@
({
appDir: '.',
baseUrl: 'lib',
//Uncomment to turn off uglify minification.
//optimize: 'none',
dir: '../demo-build',
paths: {
jade: '../../jade'
},
//This pragma excludes the CoffeeScript compiler code
//from the optimized source, since all CoffeeScript files
//are converted and inlined into the main.js built file.
//If you still want to allow dynamic loading of CoffeeScript
//files after a build, comment out the pragmasOnSave section.
pragmasOnSave: {
excludeJade: true
},
modules: [
{
name: "main"
}
]
})
4 changes: 4 additions & 0 deletions demo/build.sh
@@ -0,0 +1,4 @@
#!/bin/sh

rm -rf ../demo-build
node ../tools/r.js -o build.js
10 changes: 10 additions & 0 deletions demo/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>CoffeeScript Loader Plugin Demo</title>
<script data-main="lib/main" src="lib/require.js"></script>
</head>
<body>
<div id="main"></div>
</body>
</html>
8 changes: 8 additions & 0 deletions demo/lib/main.js
@@ -0,0 +1,8 @@
require({
paths: {
jade: '../../jade'
}
}, ['jade!views/welcome'], function(welcomeView){
main = document.getElementById('main')
main.innerHTML = welcomeView();
});

0 comments on commit 31c1cea

Please sign in to comment.