Permalink
Browse files

Blade middleware sourcePath argument is now resolved via `path.resolve`

Fixed a small bug in the compiler's option processing
Quoted strings can now be empty (closes #89)
File includes must not have an empty filename
Push to 2.6.2
  • Loading branch information...
1 parent 95fddd1 commit c081862259a009a90dae5caa02b77851df1f6abf @bminer committed Sep 24, 2012
Showing with 92 additions and 93 deletions.
  1. +1 −0 lib/blade.js
  2. +10 −4 lib/compiler.js
  3. +2 −2 lib/parser/blade-grammer.pegjs
  4. +78 −86 lib/parser/index.js
  5. +1 −1 package.json
View
1 lib/blade.js
@@ -101,6 +101,7 @@ function middleware(sourcePath, options) {
'minify': process.env.NODE_ENV == "production",
'includeSource': process.env.NODE_ENV == "development"
};
+ sourcePath = path.resolve(sourcePath);
options.compileOptions.basedir = sourcePath;
var fileCache = {}, pluginPath = path.resolve(__dirname + "/../plugins/");
return function(req, res, next) {
View
14 lib/compiler.js
@@ -35,7 +35,7 @@ function Compiler(string, opts) {
this[i] = this.options[i];
else
{
- this[i] = [];
+ this[i] = copy[i] instanceof Array ? [] : {};
for(var j in copy[i])
this[i][j] = copy[i][j];
}
@@ -440,7 +440,12 @@ Compiler.prototype._compileNode = function(node) {
if(node.exposing)
for(var i = 0; i < node.exposing.length; i++)
exposedVarList += "," + JSON.stringify(node.exposing[i]) + "," + node.exposing[i];
- if(node.filename)
+ if(node.code)
+ {
+ this._pushOff(ns + ".r.include(" + node.code + "," + ns + ");");
+ this.unknownDependencies = true;
+ }
+ else if(node.filename.length > 0)
{
this._pushOff(ns + ".r.include(" + JSON.stringify(node.filename) + "," +
ns + exposedVarList + ");");
@@ -450,8 +455,9 @@ Compiler.prototype._compileNode = function(node) {
}
else
{
- this._pushOff(ns + ".r.include(" + node.code + "," + ns + ");");
- this.unknownDependencies = true;
+ var e = new Error("Invalid include statement: You must specify a filename");
+ e.line = node.line, e.column = node.col;
+ throw e;
}
break;
case 'block':
View
4 lib/parser/blade-grammer.pegjs
@@ -459,11 +459,11 @@ whitespace "whitespace (space or horizontal tab)" =
quoted_string "quoted string" =
"'"
- data: ("\\" escaped:. {return "\\" + escaped;} / [^'])+
+ data: ("\\" escaped:. {return "\\" + escaped;} / [^'])*
"'" {return eval("'" + data.join("") + "'");}
/
'"'
- data: ("\\" escaped:. {return "\\" + escaped;} / [^"])+
+ data: ("\\" escaped:. {return "\\" + escaped;} / [^"])*
'"' {return eval('"' + data.join("") + '"');}
text_until_eol "some text before the end of the line" =
View
164 lib/parser/index.js
@@ -4130,6 +4130,7 @@ module.exports = (function(){
}
}
if (result0 !== null) {
+ result1 = [];
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 92) {
@@ -4178,61 +4179,56 @@ module.exports = (function(){
}
}
}
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- pos2 = clone(pos);
- pos3 = clone(pos);
- if (input.charCodeAt(pos.offset) === 92) {
- result2 = "\\";
+ while (result2 !== null) {
+ result1.push(result2);
+ pos2 = clone(pos);
+ pos3 = clone(pos);
+ if (input.charCodeAt(pos.offset) === 92) {
+ result2 = "\\";
+ advance(pos, 1);
+ } else {
+ result2 = null;
+ if (reportFailures === 0) {
+ matchFailed("\"\\\\\"");
+ }
+ }
+ if (result2 !== null) {
+ if (input.length > pos.offset) {
+ result3 = input.charAt(pos.offset);
advance(pos, 1);
} else {
- result2 = null;
+ result3 = null;
if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
+ matchFailed("any character");
}
}
- if (result2 !== null) {
- if (input.length > pos.offset) {
- result3 = input.charAt(pos.offset);
- advance(pos, 1);
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = clone(pos3);
- }
+ if (result3 !== null) {
+ result2 = [result2, result3];
} else {
result2 = null;
pos = clone(pos3);
}
- if (result2 !== null) {
- result2 = (function(offset, line, column, escaped) {return "\\" + escaped;})(pos2.offset, pos2.line, pos2.column, result2[1]);
- }
- if (result2 === null) {
- pos = clone(pos2);
- }
- if (result2 === null) {
- if (/^[^']/.test(input.charAt(pos.offset))) {
- result2 = input.charAt(pos.offset);
- advance(pos, 1);
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^']");
- }
+ } else {
+ result2 = null;
+ pos = clone(pos3);
+ }
+ if (result2 !== null) {
+ result2 = (function(offset, line, column, escaped) {return "\\" + escaped;})(pos2.offset, pos2.line, pos2.column, result2[1]);
+ }
+ if (result2 === null) {
+ pos = clone(pos2);
+ }
+ if (result2 === null) {
+ if (/^[^']/.test(input.charAt(pos.offset))) {
+ result2 = input.charAt(pos.offset);
+ advance(pos, 1);
+ } else {
+ result2 = null;
+ if (reportFailures === 0) {
+ matchFailed("[^']");
}
}
}
- } else {
- result1 = null;
}
if (result1 !== null) {
if (input.charCodeAt(pos.offset) === 39) {
@@ -4277,6 +4273,7 @@ module.exports = (function(){
}
}
if (result0 !== null) {
+ result1 = [];
pos2 = clone(pos);
pos3 = clone(pos);
if (input.charCodeAt(pos.offset) === 92) {
@@ -4325,61 +4322,56 @@ module.exports = (function(){
}
}
}
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- pos2 = clone(pos);
- pos3 = clone(pos);
- if (input.charCodeAt(pos.offset) === 92) {
- result2 = "\\";
+ while (result2 !== null) {
+ result1.push(result2);
+ pos2 = clone(pos);
+ pos3 = clone(pos);
+ if (input.charCodeAt(pos.offset) === 92) {
+ result2 = "\\";
+ advance(pos, 1);
+ } else {
+ result2 = null;
+ if (reportFailures === 0) {
+ matchFailed("\"\\\\\"");
+ }
+ }
+ if (result2 !== null) {
+ if (input.length > pos.offset) {
+ result3 = input.charAt(pos.offset);
advance(pos, 1);
} else {
- result2 = null;
+ result3 = null;
if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
+ matchFailed("any character");
}
}
- if (result2 !== null) {
- if (input.length > pos.offset) {
- result3 = input.charAt(pos.offset);
- advance(pos, 1);
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = clone(pos3);
- }
+ if (result3 !== null) {
+ result2 = [result2, result3];
} else {
result2 = null;
pos = clone(pos3);
}
- if (result2 !== null) {
- result2 = (function(offset, line, column, escaped) {return "\\" + escaped;})(pos2.offset, pos2.line, pos2.column, result2[1]);
- }
- if (result2 === null) {
- pos = clone(pos2);
- }
- if (result2 === null) {
- if (/^[^"]/.test(input.charAt(pos.offset))) {
- result2 = input.charAt(pos.offset);
- advance(pos, 1);
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\"]");
- }
+ } else {
+ result2 = null;
+ pos = clone(pos3);
+ }
+ if (result2 !== null) {
+ result2 = (function(offset, line, column, escaped) {return "\\" + escaped;})(pos2.offset, pos2.line, pos2.column, result2[1]);
+ }
+ if (result2 === null) {
+ pos = clone(pos2);
+ }
+ if (result2 === null) {
+ if (/^[^"]/.test(input.charAt(pos.offset))) {
+ result2 = input.charAt(pos.offset);
+ advance(pos, 1);
+ } else {
+ result2 = null;
+ if (reportFailures === 0) {
+ matchFailed("[^\"]");
}
}
}
- } else {
- result1 = null;
}
if (result1 !== null) {
if (input.charCodeAt(pos.offset) === 34) {
View
2 package.json
@@ -15,7 +15,7 @@
"live binding",
"meteor"
],
- "version": "2.6.1",
+ "version": "2.6.2",
"homepage": "https://github.com/bminer/node-blade",
"repository": {
"type": "git",

0 comments on commit c081862

Please sign in to comment.