Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function rethrow(err, str, filename, lineno){
+ lineno + '\n'
+ context + '\n\n'
+ err.message;

throw err;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ var parse = exports.parse = function(str, options){
var stri = str[i];
if (str.slice(i, open.length + i) == open) {
i += open.length

var prefix, postfix, line = (compileDebug ? '__stack.lineno=' : '') + lineno;
switch (str[i]) {
case '=':
Expand All @@ -141,8 +141,13 @@ var parse = exports.parse = function(str, options){
postfix = "; buf.push('";
}

var end = str.indexOf(close, i)
, js = str.substring(i, end)
var end = str.indexOf(close, i);

if (end < 0){
end = str.length;
}

var js = str.substring(i, end)
, start = i
, include = null
, n = 0;
Expand Down Expand Up @@ -207,14 +212,14 @@ var parse = exports.parse = function(str, options){
var compile = exports.compile = function(str, options){
options = options || {};
var escape = options.escape || utils.escape;

var input = JSON.stringify(str)
, compileDebug = options.compileDebug !== false
, client = options.client
, filename = options.filename
? JSON.stringify(options.filename)
: 'undefined';

if (compileDebug) {
// Adds the fancy stack trace meta info
str = [
Expand All @@ -229,7 +234,7 @@ var compile = exports.compile = function(str, options){
} else {
str = exports.parse(str, options);
}

if (options.debug) console.log(str);
if (client) str = 'escape = escape || ' + escape.toString() + ';\n' + str;

Expand Down