Permalink
Browse files

Release 0.27.7

  • Loading branch information...
1 parent 2853712 commit c8d593ad357133a0ecb15e1cb39bdcb0616bb3ff @tj tj committed Nov 5, 2012
Showing with 30 additions and 10 deletions.
  1. +7 −0 History.md
  2. +20 −6 jade.js
  3. +2 −2 jade.min.js
  4. +0 −1 lib/lexer.js
  5. +1 −1 package.json
View
@@ -1,4 +1,11 @@
+0.27.7 / 2012-11-05
+==================
+
+ * fix each/else clause for enumerated objects
+ * fix #764 (incorrect line number for error messages)
+ * fix double-escaping of interpolated js slashes. Closes #784
+
0.27.6 / 2012-10-05
==================
View
26 jade.js
@@ -483,8 +483,9 @@ Compiler.prototype = {
*/
visitText: function(text){
- text = utils.text(text.val.replace(/\\/g, '\\\\'));
+ text = utils.text(text.val.replace(/\\/g, '_SLASH_'));
if (this.escape) text = escape(text);
+ text = text.replace(/_SLASH_/g, '\\\\');
this.buffer(text);
},
@@ -587,15 +588,23 @@ Compiler.prototype = {
this.buf.push(''
+ ' } else {\n'
+ + ' var $$l = 0;\n'
+ ' for (var ' + each.key + ' in ' + each.obj + ') {\n'
+ + ' $$l++;'
+ ' if (' + each.obj + '.hasOwnProperty(' + each.key + ')){'
+ ' var ' + each.val + ' = ' + each.obj + '[' + each.key + '];\n');
this.visit(each.block);
this.buf.push(' }\n');
- this.buf.push(' }\n }\n}).call(this);\n');
+ this.buf.push(' }\n');
+ if (each.alternative) {
+ this.buf.push(' if ($$l === 0) {');
+ this.visit(each.alternative);
+ this.buf.push(' }');
+ }
+ this.buf.push(' }\n}).call(this);\n');
},
/**
@@ -813,7 +822,6 @@ module.exports = {
*/
coffeescript: function(str){
- str = 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>';
}
@@ -1283,6 +1291,8 @@ Lexer.prototype = {
var captures;
if (captures = /^\n *\n/.exec(this.input)) {
this.consume(captures[0].length - 1);
+
+ ++this.lineno;
if (this.pipeless) return this.tok('text', '');
return this.next();
}
@@ -3585,12 +3595,16 @@ require.register("utils.js", function(module, exports, require){
*/
var interpolate = exports.interpolate = function(str){
- return str.replace(/(\\)?([#!]){(.*?)}/g, function(str, escape, flag, code){
+ return str.replace(/(_SLASH_)?([#!]){(.*?)}/g, function(str, escape, flag, code){
+ code = code
+ .replace(/\\'/g, "'")
+ .replace(/_SLASH_/g, '\\');
+
return escape
- ? str.slice(1)
+ ? str.slice(7)
: "' + "
+ ('!' == flag ? '' : 'escape')
- + "((interp = " + code.replace(/\\'/g, "'")
+ + "((interp = " + code
+ ") == null ? '' : interp) + '";
});
};
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -174,7 +174,6 @@ Lexer.prototype = {
var captures;
if (captures = /^\n *\n/.exec(this.input)) {
this.consume(captures[0].length - 1);
-
++this.lineno;
if (this.pipeless) return this.tok('text', '');
return this.next();
View
@@ -1,7 +1,7 @@
{
"name": "jade",
"description": "Jade template engine",
- "version": "0.27.6",
+ "version": "0.27.7",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"repository": "git://github.com/visionmedia/jade",
"main": "./index.js",

0 comments on commit c8d593a

Please sign in to comment.