Skip to content

Commit

Permalink
Remove warnings when running in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ashb committed Sep 20, 2009
1 parent 613dbe7 commit 8ebded8
Showing 1 changed file with 39 additions and 33 deletions.
72 changes: 39 additions & 33 deletions lib/Template.js
Expand Up @@ -25,7 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

Template = function Template(config) {
var Template = exports.Template = function Template(config) {
config = config || {};
for (var param in config) {
this[param] = config[param];
Expand Down Expand Up @@ -60,7 +60,7 @@ Template.Constants = {
CHOMP_NONE: 0,
CHOMP_ONE: 1,
CHOMP_COLLAPSE: 2,
CHOMP_GREEDY: 3,
CHOMP_GREEDY: 3
};

Template.Exception = function(code, message) {
Expand Down Expand Up @@ -237,7 +237,7 @@ Template.Context.prototype = {
catch (e) { }
}
if (contents === undefined)
return;
return contents;

var parser = new Template.Parser(this.config);
parser.parse(contents);
Expand Down Expand Up @@ -311,12 +311,12 @@ Template.Context.prototype = {
if ('assign' in args) {
var last_seg = segments.pop();
if (Template.Stash.PRIVATE && Template.Stash.PRIVATE.exec(last_seg))
return;
return undefined;

for (var i in segments) {
var segment = segments[i];
if (Template.Stash.PRIVATE && Template.Stash.PRIVATE.exec(segment))
return;
return undefined;

if (s[segment] === undefined) {
s[segment] = {};
Expand Down Expand Up @@ -389,6 +389,7 @@ Template.Context.prototype = {
try {
return a.next();
} catch (e) { if (e !== StopIteration) throw e }
return undefined;
}

var idx = 0;
Expand Down Expand Up @@ -430,7 +431,7 @@ Template.Context.prototype = {
*/
forEach: function(a, func, novar) {
if (a === undefined || a === this.nullObj)
return;
return undefined;

var stash = this.stash;
var old_loop = this.stash.loop;
Expand Down Expand Up @@ -466,7 +467,7 @@ Template.Context.prototype = {
if (!novar && old_loop)
this.stash.loop = old_loop;
}

return undefined;
}
};

Expand Down Expand Up @@ -605,7 +606,7 @@ Template.Parser.prototype = {
this.log = function (str) {
this._log.push(str);
}
this.log(str);
return this.log(str);
}
},

Expand Down Expand Up @@ -657,7 +658,7 @@ Template.Parser.prototype = {
'+': Template.Constants.CHOMP_NONE,
'-': Template.Constants.CHOMP_ONE,
'=': Template.Constants.CHOMP_COLLAPSE,
'~': Template.Constants.CHOMP_GREEDY,
'~': Template.Constants.CHOMP_GREEDY
},

precedence: {
Expand All @@ -683,7 +684,7 @@ Template.Parser.prototype = {

'*' : 40,
'/' : 40,
DIV : 40,
DIV : 40
},

/*
Expand Down Expand Up @@ -819,15 +820,15 @@ Template.Parser.prototype = {

var initPos = pos;

while (match = re.exec(text) ) {
while ( (match = re.exec(text) ) ) {

pos = initPos + re.lastIndex - match[0].length;
// Comment in $1
if (match[1])
continue;

// Quoted pharse in $3 (and quote char in $2)
if (token = match[3]) {
if ( (token = match[3]) ) {
if (match[2] == '"') {
if (token.match("[\$\\\\]") ) {
type = 'QUOTED';
Expand Down Expand Up @@ -919,7 +920,7 @@ Template.Parser.prototype = {

var match, pre, v, dir;
var tokens = [];
while (match = re.exec(text)) {
while ( (match = re.exec(text)) ) {
pre = match[1];
dir = match[2];
if (match[3])
Expand Down Expand Up @@ -1080,7 +1081,7 @@ Template.Parser.prototype = {

var term = this.term();
if (term === undefined)
return;
return term;
return this.expr_tail(term);
},

Expand Down Expand Up @@ -1207,6 +1208,7 @@ Template.Parser.prototype = {

if (segs.length)
return {type: 'QUOTED', segments: segs };
return undefined;
},

ident: function Template$Parser$prototype$ident() {
Expand Down Expand Up @@ -1235,18 +1237,15 @@ Template.Parser.prototype = {
node: function Template$Parser$prototype$node() {
var item = this.item();

if (item === undefined)
return;
if (this.token.type == '(') {
if (item !== undefined && this.token.type == '(') {
this.consumeToken();
// args
var ret = {type: 'function_call', func: item };
ret.args = this.assertRule(this.args);
this.assertToken(')');
return ret;
} else {
return item;
}
return item;
},

args: function Template$Parser$prototype$args() {
Expand Down Expand Up @@ -1333,7 +1332,7 @@ Template.Parser.prototype = {
ret = { type: 'interpret', term: ident };
return ret;
default:
return;
return undefined;
}

},
Expand Down Expand Up @@ -1392,6 +1391,7 @@ Template.Parser.prototype = {

return ret;
}
return undefined;
},

params: function Template$Parser$prototype$params() {
Expand Down Expand Up @@ -1421,7 +1421,7 @@ Template.Parser.prototype = {
} else {
ret.to = this.item();
if (ret.to === undefined)
return;
return undefined;
}

this.assertToken('ASSIGN');
Expand Down Expand Up @@ -1484,15 +1484,15 @@ Template.Parser.prototype = {
// Not an expression that starts with an ident (probably quoted)
expr = this.expr();
if (!expr)
return;
return undefined;
}

}

if (expr) {
return this.postfixed_condition(expr);
}

return undefined;
},

// called with an ident or a LITERAL, and the first ASSIGN already consumed
Expand Down Expand Up @@ -1592,6 +1592,8 @@ Template.Parser.prototype = {
case 'NEXT':
case 'LAST':
return this.consumeToken();
default:
return undefined;
}
},

Expand All @@ -1611,6 +1613,7 @@ Template.Parser.prototype = {
this.assertToken('END');
return ret;
}
return undefined;
},

loopvar: function Template$Parser$prototype$loopvar() {
Expand Down Expand Up @@ -1647,7 +1650,7 @@ Template.Parser.prototype = {
return this.consumeToken();
} else if (this.token.type == ';') {
this.consumeToken();
return;
return undefined;
} else {
var ret = this.assertRule(this.statement);
this.assertToken(';');
Expand Down Expand Up @@ -1690,6 +1693,7 @@ Template.Parser.prototype = {

return ret;
}
return undefined;
},

conditionElse: function Template$Parser$prototype$conditionElse(cond) {
Expand Down Expand Up @@ -1735,15 +1739,15 @@ Template.Parser.prototype = {
ident = this.ident();

if (ident === undefined)
return
return ident;

this.assertToken('ASSIGN');
return this.setlist_tail(ident);
},

block: function Template$Parser$prototype$block() {
if (this.token.type != 'BLOCK')
return;
return undefined;

this.consumeToken();

Expand Down Expand Up @@ -1772,7 +1776,7 @@ Template.Parser.prototype = {
filename: function Template$Parser$prototype$filename() {
var fn = this.filepart();
if (fn === undefined)
return;
return fn;

while (this.token.type == 'DOT') {
this.consumeToken();
Expand All @@ -1789,6 +1793,7 @@ Template.Parser.prototype = {
{
return this.consumeToken();
}
return undefined;
},

metadata: function Template$Parser$prototype$metadata() {
Expand Down Expand Up @@ -1817,6 +1822,7 @@ Template.Parser.prototype = {

if (meta.length)
return meta;
return undefined;
},

lnameargs: function Template$Parser$prototype$lnameargs() {
Expand Down Expand Up @@ -1889,6 +1895,7 @@ Template.Parser.prototype = {

if (names.length)
return names;
return undefined;
},

name: function Template$Parser$prototype$name() {
Expand All @@ -1908,7 +1915,7 @@ Template.Parser.prototype = {
var valid = ['WRAPPER'
].indexOf(this.token.type) != -1;
if (!valid)
return;
return undefined;

var type = this.consumeToken().type;
var block = this.assertRule(this.nameargs);
Expand All @@ -1926,7 +1933,7 @@ Template.Parser.prototype = {

filter: function Template$Parser$filter() {
if (this.token.type != 'FILTER')
return;
return undefined;

var ret = this.consumeToken();

Expand All @@ -1946,7 +1953,7 @@ Template.Parser.prototype = {

switchBlock: function Template$Parser$switchBlock() {
if (this.token.type != 'SWITCH')
return;
return undefined;

var ret = this.consumeToken();

Expand Down Expand Up @@ -2516,14 +2523,13 @@ Template.Interpreter.prototype = {
return 'parseInt'+ret;
else
return ret;
},

}

};
/*
* END OF Template.Interpreter
*/


log = [];
var log = [];

0 comments on commit 8ebded8

Please sign in to comment.