Skip to content

Commit

Permalink
Release 0.22.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 4, 2012
1 parent dc99938 commit 3e9c448
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

0.22.1 / 2012-04-04
==================

* Fixed source tags. now self-closing. Closes #308
* Fixed: escape backslashes in coffeescript filter

0.22.0 / 2012-03-22
==================

Expand Down
71 changes: 36 additions & 35 deletions jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var nodes = require('./nodes')
, inlineTags = require('./inline-tags')
, utils = require('./utils');


if (!Object.keys) {
Object.keys = function(obj){
var arr = [];
Expand All @@ -76,9 +76,9 @@ var nodes = require('./nodes')
}
}
return arr;
}
}
}

if (!String.prototype.trimLeft) {
String.prototype.trimLeft = function(){
return this.replace(/^\s+/, '');
Expand Down Expand Up @@ -111,13 +111,13 @@ var Compiler = module.exports = function Compiler(node, options) {
*/

Compiler.prototype = {

/**
* Compile parse tree to JavaScript.
*
* @api public
*/

compile: function(){
this.buf = ['var interp;'];
this.lastBufferedIdx = -1;
Expand All @@ -133,43 +133,43 @@ Compiler.prototype = {
* @param {string} name
* @api public
*/

setDoctype: function(name){
var doctype = doctypes[(name || 'default').toLowerCase()];
doctype = doctype || '<!DOCTYPE ' + name + '>';
this.doctype = doctype;
this.terse = '5' == name || 'html' == name;
this.xml = 0 == this.doctype.indexOf('<?xml');
},

/**
* Buffer the given `str` optionally escaped.
*
* @param {String} str
* @param {Boolean} esc
* @api public
*/

buffer: function(str, esc){
if (esc) str = utils.escape(str);

if (this.lastBufferedIdx == this.buf.length) {
this.lastBuffered += str;
this.buf[this.lastBufferedIdx - 1] = "buf.push('" + this.lastBuffered + "');"
} else {
this.buf.push("buf.push('" + str + "');");
this.lastBuffered = str;
this.lastBufferedIdx = this.buf.length;
}
}
},

/**
* Visit `node`.
*
* @param {Node} node
* @api public
*/

visit: function(node){
var debug = this.debug;

Expand All @@ -192,14 +192,14 @@ Compiler.prototype = {

if (debug) this.buf.push('__jade.shift();');
},

/**
* Visit `node`.
*
* @param {Node} node
* @api public
*/

visitNode: function(node){
var name = node.constructor.name
|| node.constructor.toString().match(/function ([^(\s]+)()/)[1];
Expand All @@ -221,7 +221,7 @@ Compiler.prototype = {
this.buf.push('}');
this.withinCase = _;
},

/**
* Visit when `node`.
*
Expand Down Expand Up @@ -264,7 +264,7 @@ Compiler.prototype = {
this.visit(block.nodes[i]);
}
},

/**
* Visit `doctype`. Sets terse mode to `true` when html 5
* is used, causing self-closing tags to end with ">" vs "/>",
Expand All @@ -273,7 +273,7 @@ Compiler.prototype = {
* @param {Doctype} doctype
* @api public
*/

visitDoctype: function(doctype){
if (doctype && (doctype.val || !this.doctype)) {
this.setDoctype(doctype.val || 'default');
Expand All @@ -296,7 +296,7 @@ Compiler.prototype = {
, args = mixin.args || '';

if (mixin.block) {
this.buf.push('var ' + name + ' = function(' + args + '){');
this.buf.push('function ' + name + '(' + args + '){');
this.visit(mixin.block);
this.buf.push('}');
} else {
Expand All @@ -311,7 +311,7 @@ Compiler.prototype = {
* @param {Tag} tag
* @api public
*/

visitTag: function(tag){
this.indents++;
var name = tag.name;
Expand Down Expand Up @@ -357,14 +357,14 @@ Compiler.prototype = {
}
this.indents--;
},

/**
* Visit `filter`, throwing when the filter does not exist.
*
* @param {Filter} filter
* @api public
*/

visitFilter: function(filter){
var fn = filters[filter.name];

Expand All @@ -385,41 +385,41 @@ Compiler.prototype = {
this.buffer(utils.text(fn(text, filter.attrs)));
}
},

/**
* Visit `text` node.
*
* @param {Text} text
* @api public
*/

visitText: function(text){
text = utils.text(text.nodes.join(''));
if (this.escape) text = escape(text);
this.buffer(text);
this.buffer('\\n');
},

/**
* Visit a `comment`, only buffering when the buffer flag is set.
*
* @param {Comment} comment
* @api public
*/

visitComment: function(comment){
if (!comment.buffer) return;
if (this.pp) this.buffer('\\n' + Array(this.indents + 1).join(' '));
this.buffer('<!--' + utils.escape(comment.val) + '-->');
},

/**
* Visit a `BlockComment`.
*
* @param {Comment} comment
* @api public
*/

visitBlockComment: function(comment){
if (!comment.buffer) return;
if (0 == comment.val.trim().indexOf('if')) {
Expand All @@ -432,7 +432,7 @@ Compiler.prototype = {
this.buffer('-->');
}
},

/**
* Visit `code`, respecting buffer / escape flags.
* If the code is followed by a block, wrap it in
Expand All @@ -441,7 +441,7 @@ Compiler.prototype = {
* @param {Code} code
* @api public
*/

visitCode: function(code){
// Wrap code blocks with {}.
// we only wrap unbuffered code blocks ATM
Expand All @@ -465,14 +465,14 @@ Compiler.prototype = {
if (!code.buffer) this.buf.push('}');
}
},

/**
* Visit `each` block.
*
* @param {Each} each
* @api public
*/

visitEach: function(each){
this.buf.push(''
+ '// iterate ' + each.obj + '\n'
Expand All @@ -496,14 +496,14 @@ Compiler.prototype = {

this.buf.push(' }\n }\n}).call(this);\n');
},

/**
* Visit `attrs`.
*
* @param {Array} attrs
* @api public
*/

visitAttributes: function(attrs){
var buf = []
, classes = [];
Expand Down Expand Up @@ -663,7 +663,7 @@ module.exports = {

coffeescript: function(str){
str = str.replace(/\\n/g, '\n');
var js = require('coffee-script').compile(str).replace(/\n/g, '\\n');
var js = require('coffee-script').compile(str).replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
return '<script type="text/javascript">\\n' + js + '</script>';
}
};
Expand Down Expand Up @@ -721,7 +721,7 @@ var Parser = require('./parser')
* Library version.
*/

exports.version = '0.21.0';
exports.version = '0.22.1';

/**
* Expose self closing tags.
Expand Down Expand Up @@ -3093,6 +3093,7 @@ module.exports = [
, 'img'
, 'link'
, 'input'
, 'source'
, 'area'
, 'base'
, 'col'
Expand Down
4 changes: 2 additions & 2 deletions jade.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/jade.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var Parser = require('./parser')
* Library version.
*/

exports.version = '0.22.0';
exports.version = '0.22.1';

/**
* Expose self closing tags.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jade",
"description": "Jade template engine",
"version": "0.22.0",
"version": "0.22.1",
"author": "TJ Holowaychuk <[email protected]>",
"repository": "git://github.com/visionmedia/jade",
"main": "./index.js",
Expand Down

0 comments on commit 3e9c448

Please sign in to comment.