Comparing version 1.0.2 to 1.1.0
@@ -5,3 +5,3 @@ { | ||
"description": "Jade template runtime", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "template" |
@@ -29,3 +29,2 @@ 'use strict'; | ||
this.debug = false !== options.compileDebug; | ||
this.inMixin = false; | ||
this.indents = 0; | ||
@@ -68,5 +67,2 @@ this.parentIndents = 0; | ||
name = name || 'default'; | ||
if (name.toLowerCase() === '5') { | ||
throw new Error('`doctype 5` is deprecated, you must now use `doctype html`'); | ||
} | ||
this.doctype = doctypes[name.toLowerCase()] || '<!DOCTYPE ' + name + '>'; | ||
@@ -295,5 +291,2 @@ this.terse = this.doctype.toLowerCase() == '<!doctype html>'; | ||
visitMixinBlock: function(block){ | ||
if (!this.inMixin) { | ||
throw new Error('Anonymous blocks are not allowed unless they are part of a mixin.'); | ||
} | ||
if (this.pp) this.buf.push("jade.indent.push('" + Array(this.indents + 1).join(' ') + "');"); | ||
@@ -389,5 +382,3 @@ this.buf.push('block && block();'); | ||
this.parentIndents++; | ||
this.inMixin = true; | ||
this.visit(block); | ||
this.inMixin = false; | ||
this.parentIndents--; | ||
@@ -630,3 +621,2 @@ this.buf.push('};'); | ||
var classEscaping = []; | ||
var visited = []; | ||
@@ -637,5 +627,2 @@ attrs.forEach(function(attr){ | ||
if (key !== 'class' && visited.indexOf(key) !== -1) throw new Error('Duplicate key "' + key + '" is not allowed.'); | ||
visited.push(key); | ||
if (key === 'class') { | ||
@@ -642,0 +629,0 @@ classes.push(attr.val); |
@@ -248,3 +248,7 @@ 'use strict'; | ||
} | ||
return this.scan(/^(?:doctype) *([^\n]+)?/, 'doctype'); | ||
var node = this.scan(/^(?:doctype) *([^\n]+)?/, 'doctype'); | ||
if (node && node.val && node.val.trim() === '5') { | ||
throw new Error('`doctype 5` is deprecated, you must now use `doctype html`'); | ||
} | ||
return node; | ||
}, | ||
@@ -355,3 +359,3 @@ | ||
var captures; | ||
if (captures = /^block\s*\n/.exec(this.input)) { | ||
if (captures = /^block\s*(\n|$)/.exec(this.input)) { | ||
this.consume(captures[0].length - 1); | ||
@@ -586,4 +590,3 @@ return this.tok('mixin-block'); | ||
this.consume(index + 1); | ||
tok.attrs = {}; | ||
tok.escaped = {}; | ||
tok.attrs = []; | ||
@@ -632,4 +635,7 @@ var escapedAttr = true | ||
key = key.replace(/^['"]|['"]$/g, ''); | ||
tok.escaped[key] = escapedAttr; | ||
tok.attrs[key] = '' == val ? true : val; | ||
tok.attrs.push({ | ||
name: key, | ||
val: '' == val ? true : val, | ||
escaped: escapedAttr | ||
}); | ||
key = val = ''; | ||
@@ -636,0 +642,0 @@ loc = 'key'; |
@@ -13,2 +13,3 @@ 'use strict'; | ||
var Attrs = module.exports = function Attrs() { | ||
this.attributeNames = []; | ||
this.attrs = []; | ||
@@ -37,2 +38,7 @@ this.attributeBlocks = []; | ||
Attrs.prototype.setAttribute = function(name, val, escaped){ | ||
this.attributeNames = this.attributeNames || []; | ||
if (name !== 'class' && this.attributeNames.indexOf(name) !== -1) { | ||
throw new Error('Duplicate attribute "' + name + '" is not allowed.'); | ||
} | ||
this.attributeNames.push(name); | ||
this.attrs.push({ name: name, val: val, escaped: escaped }); | ||
@@ -39,0 +45,0 @@ return this; |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var constantinople = require('constantinople'); | ||
var parseJSExpression = require('character-parser').parseMax; | ||
@@ -30,2 +31,3 @@ var extname = path.extname; | ||
this.contexts = [this]; | ||
this.inMixin = false; | ||
}; | ||
@@ -370,5 +372,14 @@ | ||
this.lexer.pipeless = false; | ||
} else block = new nodes.Block; | ||
} else { | ||
block = new nodes.Block; | ||
} | ||
var node = new nodes.Filter(tok.val, block, attrs && attrs.attrs); | ||
var options = {}; | ||
if (attrs) { | ||
attrs.attrs.forEach(function (attribute) { | ||
options[attribute.name] = constantinople.toConstant(attribute.val); | ||
}); | ||
} | ||
var node = new nodes.Filter(tok.val, block, options); | ||
node.line = this.line(); | ||
@@ -485,2 +496,5 @@ return node; | ||
var block = this.expect('mixin-block'); | ||
if (!this.inMixin) { | ||
throw new Error('Anonymous blocks are not allowed unless they are part of a mixin.'); | ||
} | ||
return new nodes.MixinBlock(); | ||
@@ -561,4 +575,6 @@ }, | ||
if ('indent' == this.peek().type) { | ||
this.inMixin = true; | ||
mixin = new nodes.Mixin(name, args, this.block(), false); | ||
this.mixins[name] = mixin; | ||
this.inMixin = false; | ||
return mixin; | ||
@@ -674,6 +690,2 @@ // call | ||
parseTag: function(){ | ||
// ast-filter look-ahead | ||
var i = 2; | ||
if ('attrs' == this.lookahead(i).type) ++i; | ||
var tok = this.advance(); | ||
@@ -709,13 +721,9 @@ var tag = new nodes.Tag(tok.val); | ||
seenAttrs = true; | ||
var tok = this.advance() | ||
, obj = tok.attrs | ||
, escaped = tok.escaped | ||
, names = Object.keys(obj); | ||
var tok = this.advance(); | ||
var attrs = tok.attrs; | ||
if (tok.selfClosing) tag.selfClosing = true; | ||
for (var i = 0, len = names.length; i < len; ++i) { | ||
var name = names[i] | ||
, val = obj[name]; | ||
tag.setAttribute(name, val, escaped[name]); | ||
for (var i = 0; i < attrs.length; i++) { | ||
tag.setAttribute(attrs[i].name, attrs[i].val, attrs[i].escaped); | ||
} | ||
@@ -737,2 +745,8 @@ continue; | ||
} | ||
if (tag.selfClosing | ||
&& ['newline', 'outdent', 'eos'].indexOf(this.peek().type) === -1 | ||
&& (this.peek().type !== 'text' || /^\s*$/.text(this.peek().val))) { | ||
throw new Error(name + ' is self closing and should not have content.'); | ||
} | ||
@@ -739,0 +753,0 @@ // (text | code | ':')? |
{ | ||
"name": "jade", | ||
"description": "Jade template engine", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -13,7 +13,7 @@ "repository": "git://github.com/visionmedia/jade", | ||
"dependencies": { | ||
"commander": "2.0.0", | ||
"commander": "2.1.0", | ||
"mkdirp": "~0.3.5", | ||
"transformers": "2.1.0", | ||
"character-parser": "1.2.0", | ||
"monocle": "1.1.50", | ||
"monocle": "1.1.51", | ||
"with": "~2.0.0", | ||
@@ -20,0 +20,0 @@ "constantinople": "~1.0.2" |
Sorry, the diff of this file is too big to display
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
935323
24027
+ Addedcommander@2.1.0(transitive)
+ Addedmonocle@1.1.51(transitive)
- Removedcommander@2.0.0(transitive)
- Removedmonocle@1.1.50(transitive)
Updatedcommander@2.1.0
Updatedmonocle@1.1.51