Permalink
Browse files

implement suggestions from @jrburke

  • Loading branch information...
Dan Williams
Dan Williams committed Sep 11, 2011
1 parent adf2331 commit 31c1cea1e4f66dc3023d80ccc3268087a224651c
View
@@ -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+.
@@ -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
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm -rf ../demo-build
+node ../tools/r.js -o build.js
View
@@ -0,0 +1,6 @@
+
+lib/main.js
+----------------
+jade!views/welcome
+lib/../../jade.js
+lib/main.js
View
@@ -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>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1 @@
+h1 Jade Templates for RequireJS
View
@@ -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"
+ }
+ ]
+})
View
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+rm -rf ../demo-build
+node ../tools/r.js -o build.js
View
@@ -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>
View
@@ -0,0 +1,8 @@
+require({
+ paths: {
+ jade: '../../jade'
+ }
+}, ['jade!views/welcome'], function(welcomeView){
+ main = document.getElementById('main')
+ main.innerHTML = welcomeView();
+});
Oops, something went wrong.

0 comments on commit 31c1cea

Please sign in to comment.