Permalink
Browse files

Release 0.11.0

  • Loading branch information...
1 parent 3a957ef commit 02f6fa456fb6866f7646131ad2ec406fe87ddabc @tj tj committed May 14, 2011
Showing with 49 additions and 11 deletions.
  1. +6 −0 History.md
  2. +39 −8 jade.js
  3. +1 −1 jade.min.js
  4. +2 −1 lib/jade.js
  5. +1 −1 package.json
View
@@ -1,4 +1,10 @@
+0.11.0 / 2011-05-14
+==================
+
+ * Added `self` object to avoid poor `with(){}` performance [masylum]
+ * Added `doctype` option [Jeremy Larkin]
+
0.10.7 / 2011-05-04
==================
View
47 jade.js
@@ -84,6 +84,7 @@ var nodes = require('./nodes')
}
+
/**
* Initialize `Compiler` with the given `node`.
*
@@ -95,6 +96,9 @@ var nodes = require('./nodes')
var Compiler = module.exports = function Compiler(node, options) {
this.options = options = options || {};
this.node = node;
+ this.hasCompiledDoctype = false;
+ this.hasCompiledTag = false;
+ if (options.doctype) this.setDoctype(options.doctype);
};
/**
@@ -114,6 +118,23 @@ Compiler.prototype = {
this.visit(this.node);
return this.buf.join('\n');
},
+
+ /**
+ * Sets the default doctype `name`. Sets terse mode to `true` when
+ * html 5 is used, causing self-closing tags to end with ">" vs "/>",
+ * and boolean attributes are not mirrored.
+ *
+ * @param {string} name
+ * @api public
+ */
+
+ setDoctype: function(name){
+ var doctype = doctypes[name || 'default'];
+ if (!doctype) throw new Error('unknown doctype "' + name + '"');
+ this.doctype = doctype;
+ this.terse = '5' == name || 'html' == name;
+ this.xml = 0 == this.doctype.indexOf('<?xml');
+ },
/**
* Buffer the given `str` optionally escaped.
@@ -189,12 +210,12 @@ Compiler.prototype = {
*/
visitDoctype: function(doctype){
- var name = doctype.val;
- if ('5' == name) this.terse = true;
- doctype = doctypes[name || 'default'];
- this.xml = 0 == doctype.indexOf('<?xml');
- if (!doctype) throw new Error('unknown doctype "' + name + '"');
- this.buffer(doctype);
+ if (doctype && (doctype.val || !this.doctype)) {
+ this.setDoctype(doctype.val || 'default');
+ }
+
+ if (this.doctype) this.buffer(this.doctype);
+ this.hasCompiledDoctype = true;
},
/**
@@ -208,6 +229,13 @@ Compiler.prototype = {
visitTag: function(tag){
var name = tag.name;
+ if (!this.hasCompiledTag) {
+ if (!this.hasCompiledDoctype && 'html' == name) {
+ this.visitDoctype();
+ }
+ this.hasCompiledTag = true;
+ }
+
if (~selfClosing.indexOf(name) && !this.xml) {
this.buffer('<' + name);
this.visitAttributes(tag.attrs);
@@ -553,7 +581,7 @@ var Parser = require('./parser')
* Library version.
*/
-exports.version = '0.10.7';
+exports.version = '0.11.0';
/**
* Intermediate JavaScript cache.
@@ -715,7 +743,9 @@ function parse(str, options){
+ attrs.toString() + '\n\n'
+ escape.toString() + '\n\n'
+ 'var buf = [];\n'
- + 'with (locals || {}) {' + js + '}'
+ + (options.self
+ ? 'var self = locals || {}, __ = locals.__;\n' + js
+ : 'with (locals || {}) {' + js + '}')
+ 'return buf.join("");';
} catch (err) {
process.compile(js, filename || 'Jade');
@@ -841,6 +871,7 @@ exports.renderFile = function(path, options, fn){
});
}
};
+
}); // module: jade.js
require.register("lexer.js", function(module, exports, require){
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -19,7 +19,7 @@ var Parser = require('./parser')
* Library version.
*/
-exports.version = '0.10.7';
+exports.version = '0.11.0';
/**
* Intermediate JavaScript cache.
@@ -234,6 +234,7 @@ exports.compile = function(str, options){
* - `filename` Used in exceptions, and required by `cache`
* - `cache` Cache intermediate JavaScript in memory keyed by `filename`
* - `compiler` Compiler to replade jade's default
+ * - `doctype` Specify the default doctype
*
* @param {String|Buffer} str
* @param {Object} options
View
@@ -1,7 +1,7 @@
{
"name": "jade",
"description": "Jade template engine",
- "version": "0.10.7",
+ "version": "0.11.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"repository": "git://github.com/visionmedia/jade",
"main": "./index.js",

0 comments on commit 02f6fa4

Please sign in to comment.