Comparing version 0.26.3 to 0.27.0
@@ -92,6 +92,5 @@ | ||
setDoctype: function(name){ | ||
var doctype = doctypes[(name || 'default').toLowerCase()]; | ||
doctype = doctype || '<!DOCTYPE ' + name + '>'; | ||
this.doctype = doctype; | ||
this.terse = '5' == name || 'html' == name; | ||
name = (name && name.toLowerCase()) || 'default'; | ||
this.doctype = doctypes[name] || '<!DOCTYPE ' + name + '>'; | ||
this.terse = this.doctype.toLowerCase() == '<!doctype html>'; | ||
this.xml = 0 == this.doctype.indexOf('<?xml'); | ||
@@ -129,3 +128,3 @@ }, | ||
*/ | ||
prettyIndent: function(offset, newline){ | ||
@@ -238,3 +237,3 @@ offset = offset || 0; | ||
, pp = this.pp | ||
// Block keyword has a special meaning in mixins | ||
@@ -247,7 +246,7 @@ if (this.parentIndents && block.mode) { | ||
} | ||
// Pretty print multi-line text | ||
if (pp && len > 1 && !escape && block.nodes[0].isText && block.nodes[1].isText) | ||
this.prettyIndent(1, true); | ||
for (var i = 0; i < len; ++i) { | ||
@@ -257,3 +256,3 @@ // Pretty print text | ||
this.prettyIndent(1, false); | ||
this.visit(block.nodes[i]); | ||
@@ -302,8 +301,8 @@ // Multiple text nodes are separated by newlines | ||
if (block || attrs.length) { | ||
this.buf.push(name + '.call({'); | ||
if (block) { | ||
this.buf.push('block: function(){'); | ||
// Render block with no indents, dynamically added when rendered | ||
@@ -316,3 +315,3 @@ this.parentIndents++; | ||
this.parentIndents--; | ||
if (attrs.length) { | ||
@@ -324,3 +323,3 @@ this.buf.push('},'); | ||
} | ||
if (attrs.length) { | ||
@@ -335,3 +334,3 @@ var val = this.attrs(attrs); | ||
} | ||
if (args) { | ||
@@ -342,3 +341,3 @@ this.buf.push('}, ' + args + ');'); | ||
} | ||
} else { | ||
@@ -531,3 +530,9 @@ this.buf.push(name + '(' + args + ');'); | ||
+ ';(function(){\n' | ||
+ ' if (\'number\' == typeof ' + each.obj + '.length) {\n' | ||
+ ' if (\'number\' == typeof ' + each.obj + '.length) {\n'); | ||
if (each.alternative) { | ||
this.buf.push(' if (' + each.obj + '.length) {'); | ||
} | ||
this.buf.push('' | ||
+ ' for (var ' + each.key + ' = 0, $$l = ' + each.obj + '.length; ' + each.key + ' < $$l; ' + each.key + '++) {\n' | ||
@@ -538,4 +543,11 @@ + ' var ' + each.val + ' = ' + each.obj + '[' + each.key + '];\n'); | ||
this.buf.push(' }\n'); | ||
if (each.alternative) { | ||
this.buf.push(' } else {'); | ||
this.visit(each.alternative); | ||
this.buf.push(' }'); | ||
} | ||
this.buf.push('' | ||
+ ' }\n' | ||
+ ' } else {\n' | ||
@@ -627,7 +639,7 @@ + ' for (var ' + each.key + ' in ' + each.obj + ') {\n' | ||
return true; | ||
// Check numbers | ||
if (!isNaN(Number(val))) | ||
return true; | ||
// Check arrays | ||
@@ -637,3 +649,3 @@ var matches; | ||
return matches[1].split(',').every(isConstant); | ||
return false; | ||
@@ -656,2 +668,2 @@ } | ||
.replace(/"/g, '"'); | ||
} | ||
} |
@@ -23,3 +23,3 @@ /*! | ||
exports.version = '0.26.3'; | ||
exports.version = '0.27.0'; | ||
@@ -122,2 +122,16 @@ /** | ||
/** | ||
* Strip any UTF-8 BOM off of the start of `str`, if it exists. | ||
* | ||
* @param {String} str | ||
* @return {String} | ||
* @api private | ||
*/ | ||
function stripBOM(str){ | ||
return 0xFEFF == str.charCodeAt(0) | ||
? str.substring(1) | ||
: str; | ||
} | ||
/** | ||
* Compile a `Function` representation of the given jade `str`. | ||
@@ -145,2 +159,4 @@ * | ||
str = stripBOM(String(str)); | ||
if (options.compileDebug !== false) { | ||
@@ -150,3 +166,3 @@ fn = [ | ||
, 'try {' | ||
, parse(String(str), options) | ||
, parse(str, options) | ||
, '} catch (err) {' | ||
@@ -157,3 +173,3 @@ , ' rethrow(err, __jade[0].filename, __jade[0].lineno);' | ||
} else { | ||
fn = parse(String(str), options); | ||
fn = parse(str, options); | ||
} | ||
@@ -160,0 +176,0 @@ |
@@ -388,2 +388,6 @@ | ||
node.block = this.block(); | ||
if (this.peek().type == 'code' && this.peek().val == 'else') { | ||
this.advance(); | ||
node.alternative = this.block(); | ||
} | ||
return node; | ||
@@ -390,0 +394,0 @@ }, |
{ | ||
"name": "jade", | ||
"description": "Jade template engine", | ||
"version": "0.26.3", | ||
"version": "0.27.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/visionmedia/jade", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211407
6159