Comparing version 0.4.0 to 0.4.1
0.4.1 / 2011-04-21 | ||
================== | ||
* Fixed error context | ||
0.4.0 / 2011-04-21 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -19,3 +19,3 @@ | ||
exports.version = '0.4.0'; | ||
exports.version = '0.4.1'; | ||
@@ -79,10 +79,11 @@ /** | ||
var lines = str.split('\n') | ||
, start = Math.max( lineno - 3, 0 ) | ||
, end = Math.min( lines.length - start , lineno + 3 ); | ||
, start = Math.max(lineno - 3, 0) | ||
, end = Math.min(lines.length, lineno + 3); | ||
// Error context | ||
var context = lines.slice(start, end).map(function(line, i){ | ||
return (i + 1 != lineno ? ' ' : ' >> ') | ||
+ (i + start + 1) | ||
+ "| " | ||
var curr = i + start + 1; | ||
return (curr == lineno ? ' >> ' : ' ') | ||
+ curr | ||
+ '| ' | ||
+ line; | ||
@@ -126,16 +127,16 @@ }).join('\n'); | ||
var prefix, postfix; | ||
var prefix, postfix, line = '__stack.lineno=' + lineno; | ||
switch (str[i]) { | ||
case '=': | ||
prefix = "', escape("; | ||
postfix = "), '"; | ||
prefix = "', escape((" + line + ', '; | ||
postfix = ")), '"; | ||
++i; | ||
break; | ||
case '-': | ||
prefix = "', "; | ||
postfix = ", '"; | ||
prefix = "', (" + line + ', '; | ||
postfix = "), '"; | ||
++i; | ||
break; | ||
default: | ||
prefix = "'); __stack.lineno="+lineno+"; "; | ||
prefix = "');" + line + ';'; | ||
postfix = "; buf.push('"; | ||
@@ -164,2 +165,3 @@ } | ||
} | ||
buf.push("');\n}\nreturn buf.join('');"); | ||
@@ -188,3 +190,3 @@ return buf.join(''); | ||
str = [ | ||
'var __stack = { lineno: 1, input: '+input+', filename: '+filename+' };', | ||
'var __stack = { lineno: 1, input: ' + input + ', filename: ' + filename + ' };', | ||
rethrow.toString(), | ||
@@ -191,0 +193,0 @@ 'try {', |
{ | ||
"name": "ejs", | ||
"description": "Embedded JavaScript templates", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -6,0 +6,0 @@ "keywords": ["template", "engine", "ejs"], |
136979
787