handlebars
Advanced tools
Comparing version 1.0.4-beta to 1.0.5-beta
@@ -9,3 +9,3 @@ var Handlebars = require("./handlebars/base"); | ||
require("./handlebars/compiler"); | ||
require("./handlebars/vm"); | ||
require("./handlebars/runtime"); | ||
@@ -12,0 +12,0 @@ // BEGIN(BROWSER) |
// BEGIN(BROWSER) | ||
var Handlebars = {}; | ||
Handlebars.VERSION = "1.0.beta.2"; | ||
Handlebars.VERSION = "1.0.beta.5"; | ||
@@ -26,2 +26,4 @@ Handlebars.helpers = {}; | ||
var toString = Object.prototype.toString, functionType = "[object Function]"; | ||
Handlebars.registerHelper('blockHelperMissing', function(context, options) { | ||
@@ -32,7 +34,5 @@ var inverse = options.inverse || function() {}, fn = options.fn; | ||
var ret = ""; | ||
var type = Object.prototype.toString.call(context); | ||
var type = toString.call(context); | ||
if(type === "[object Function]") { | ||
context = context(); | ||
} | ||
if(type === functionType) { context = context.call(this); } | ||
@@ -72,2 +72,5 @@ if(context === true) { | ||
Handlebars.registerHelper('if', function(context, options) { | ||
var type = toString.call(context); | ||
if(type === functionType) { context = context.call(this); } | ||
if(!context || Handlebars.Utils.isEmpty(context)) { | ||
@@ -74,0 +77,0 @@ return options.inverse(this); |
@@ -184,2 +184,3 @@ var Handlebars = require("./base"); | ||
this.opcode('invokeProgram', null, params.length, !!block.mustache.hash); | ||
this.declare('inverse', null); | ||
this.opcode('append'); | ||
@@ -225,3 +226,3 @@ }, | ||
if(mustache.escaped) { | ||
if(mustache.escaped && !this.options.noEscape) { | ||
this.opcode('appendEscaped'); | ||
@@ -320,10 +321,10 @@ } else { | ||
nameLookup: function(parent, name, type) { | ||
if (/^[0-9]+$/.test(name)) { | ||
if (/^[0-9]+$/.test(name)) { | ||
return parent + "[" + name + "]"; | ||
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) { | ||
return parent + "." + name; | ||
} | ||
else { | ||
return parent + "['" + name + "']"; | ||
return parent + "." + name; | ||
} | ||
else { | ||
return parent + "['" + name + "']"; | ||
} | ||
}, | ||
@@ -413,2 +414,8 @@ | ||
// this register will disambiguate helper lookup from finding a function in | ||
// a context. This is necessary for mustache compatibility, which requires | ||
// that context functions in blocks are evaluated by blockHelperMissing, and | ||
// then proceed as if the resulting value was provided to blockHelperMissing. | ||
this.useRegister('foundHelper'); | ||
if (!this.isChild) { | ||
@@ -447,3 +454,3 @@ var namespace = this.namespace; | ||
if (!this.isChild) { | ||
var aliases = [] | ||
var aliases = []; | ||
for (var alias in this.context.aliases) { | ||
@@ -527,6 +534,4 @@ this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; | ||
} else { | ||
toPush = topStack + " = " | ||
+ this.nameLookup('helpers', name, 'helper') | ||
+ " || " | ||
+ this.nameLookup('depth' + this.lastContext, name, 'context'); | ||
this.register('foundHelper', this.nameLookup('helpers', name, 'helper')); | ||
toPush = topStack + " = foundHelper || " + this.nameLookup('depth' + this.lastContext, name, 'context'); | ||
} | ||
@@ -544,3 +549,3 @@ | ||
this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " + | ||
topStack + " : " + this.nameLookup(topStack, name, 'context') + ");"); | ||
topStack + " : " + this.nameLookup(topStack, name, 'context') + ");"); | ||
}, | ||
@@ -627,6 +632,6 @@ | ||
this.populateCall(params, id, helperId || id, fn); | ||
this.populateCall(params, id, helperId || id, fn, program !== '{}'); | ||
}, | ||
populateCall: function(params, id, helperId, fn) { | ||
populateCall: function(params, id, helperId, fn, program) { | ||
var paramString = ["depth0"].concat(params).join(", "); | ||
@@ -641,3 +646,4 @@ var helperMissingString = ["depth0"].concat(helperId).concat(params).join(", "); | ||
this.context.aliases.functionType = '"function"'; | ||
this.source.push("if(typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }"); | ||
var condition = program ? "foundHelper && " : ""; | ||
this.source.push("if(" + condition + "typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }"); | ||
} | ||
@@ -649,3 +655,9 @@ fn.call(this, nextStack, helperMissingString, id); | ||
invokePartial: function(context) { | ||
this.pushStack("self.invokePartial(" + this.nameLookup('partials', context, 'partial') + ", '" + context + "', " + this.popStack() + ", helpers, partials);"); | ||
params = [this.nameLookup('partials', context, 'partial'), "'" + context + "'", this.popStack(), "helpers", "partials"]; | ||
if (this.options.data) { | ||
params.push("data"); | ||
} | ||
this.pushStack("self.invokePartial(" + params.join(", ") + ");"); | ||
}, | ||
@@ -741,5 +753,19 @@ | ||
var reservedWords = ("break case catch continue default delete do else finally " + | ||
"for function if in instanceof new return switch this throw " + | ||
"try typeof var void while with null true false").split(" "); | ||
var reservedWords = ( | ||
"break else new var" + | ||
" case finally return void" + | ||
" catch for switch while" + | ||
" continue function this with" + | ||
" default if throw" + | ||
" delete in try" + | ||
" do instanceof typeof" + | ||
" abstract enum int short" + | ||
" boolean export interface static" + | ||
" byte extends long super" + | ||
" char final native synchronized" + | ||
" class float package throws" + | ||
" const goto private transient" + | ||
" debugger implements protected volatile" + | ||
" double import public let yield" | ||
).split(" "); | ||
@@ -752,8 +778,8 @@ var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; | ||
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { | ||
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) { | ||
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
@@ -760,0 +786,0 @@ })(Handlebars.Compiler, Handlebars.JavaScriptCompiler); |
@@ -12,81 +12,81 @@ /* Jison generated parser */ | ||
switch (yystate) { | ||
case 1: return $$[$0-1] | ||
case 1: return $$[$0-1]; | ||
break; | ||
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]) | ||
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]); | ||
break; | ||
case 3: this.$ = new yy.ProgramNode($$[$0]) | ||
case 3: this.$ = new yy.ProgramNode($$[$0]); | ||
break; | ||
case 4: this.$ = new yy.ProgramNode([]) | ||
case 4: this.$ = new yy.ProgramNode([]); | ||
break; | ||
case 5: this.$ = [$$[$0]] | ||
case 5: this.$ = [$$[$0]]; | ||
break; | ||
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1] | ||
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; | ||
break; | ||
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0]) | ||
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0]); | ||
break; | ||
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0]) | ||
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0]); | ||
break; | ||
case 9: this.$ = $$[$0] | ||
case 9: this.$ = $$[$0]; | ||
break; | ||
case 10: this.$ = $$[$0] | ||
case 10: this.$ = $$[$0]; | ||
break; | ||
case 11: this.$ = new yy.ContentNode($$[$0]) | ||
case 11: this.$ = new yy.ContentNode($$[$0]); | ||
break; | ||
case 12: this.$ = new yy.CommentNode($$[$0]) | ||
case 12: this.$ = new yy.CommentNode($$[$0]); | ||
break; | ||
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) | ||
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); | ||
break; | ||
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) | ||
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); | ||
break; | ||
case 15: this.$ = $$[$0-1] | ||
case 15: this.$ = $$[$0-1]; | ||
break; | ||
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]) | ||
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]); | ||
break; | ||
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true) | ||
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true); | ||
break; | ||
case 18: this.$ = new yy.PartialNode($$[$0-1]) | ||
case 18: this.$ = new yy.PartialNode($$[$0-1]); | ||
break; | ||
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]) | ||
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]); | ||
break; | ||
case 20: | ||
break; | ||
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]] | ||
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]]; | ||
break; | ||
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null] | ||
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null]; | ||
break; | ||
case 23: this.$ = [[$$[$0-1]], $$[$0]] | ||
case 23: this.$ = [[$$[$0-1]], $$[$0]]; | ||
break; | ||
case 24: this.$ = [[$$[$0]], null] | ||
case 24: this.$ = [[$$[$0]], null]; | ||
break; | ||
case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; | ||
break; | ||
case 26: this.$ = [$$[$0]] | ||
case 26: this.$ = [$$[$0]]; | ||
break; | ||
case 27: this.$ = $$[$0] | ||
case 27: this.$ = $$[$0]; | ||
break; | ||
case 28: this.$ = new yy.StringNode($$[$0]) | ||
case 28: this.$ = new yy.StringNode($$[$0]); | ||
break; | ||
case 29: this.$ = new yy.IntegerNode($$[$0]) | ||
case 29: this.$ = new yy.IntegerNode($$[$0]); | ||
break; | ||
case 30: this.$ = new yy.BooleanNode($$[$0]) | ||
case 30: this.$ = new yy.BooleanNode($$[$0]); | ||
break; | ||
case 31: this.$ = new yy.HashNode($$[$0]) | ||
case 31: this.$ = new yy.HashNode($$[$0]); | ||
break; | ||
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1] | ||
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1]; | ||
break; | ||
case 33: this.$ = [$$[$0]] | ||
case 33: this.$ = [$$[$0]]; | ||
break; | ||
case 34: this.$ = [$$[$0-2], $$[$0]] | ||
case 34: this.$ = [$$[$0-2], $$[$0]]; | ||
break; | ||
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])] | ||
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])]; | ||
break; | ||
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])] | ||
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])]; | ||
break; | ||
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])] | ||
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])]; | ||
break; | ||
case 38: this.$ = new yy.IdNode($$[$0]) | ||
case 38: this.$ = new yy.IdNode($$[$0]); | ||
break; | ||
case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2]; | ||
break; | ||
case 40: this.$ = [$$[$0]] | ||
case 40: this.$ = [$$[$0]]; | ||
break; | ||
@@ -399,58 +399,64 @@ } | ||
switch($avoiding_name_collisions) { | ||
case 0: this.begin("mu"); if (yy_.yytext) return 14; | ||
case 0: | ||
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu"); | ||
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu"); | ||
if(yy_.yytext) return 14; | ||
break; | ||
case 1: return 14; | ||
break; | ||
case 2: return 24; | ||
case 2: this.popState(); return 14; | ||
break; | ||
case 3: return 16; | ||
case 3: return 24; | ||
break; | ||
case 4: return 20; | ||
case 4: return 16; | ||
break; | ||
case 5: return 19; | ||
case 5: return 20; | ||
break; | ||
case 6: return 19; | ||
break; | ||
case 7: return 23; | ||
case 7: return 19; | ||
break; | ||
case 8: return 23; | ||
break; | ||
case 9: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.begin("INITIAL"); return 15; | ||
case 9: return 23; | ||
break; | ||
case 10: return 22; | ||
case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; | ||
break; | ||
case 11: return 34; | ||
case 11: return 22; | ||
break; | ||
case 12: return 33; | ||
case 12: return 34; | ||
break; | ||
case 13: return 33; | ||
break; | ||
case 14: return 36; | ||
case 14: return 33; | ||
break; | ||
case 15: /*ignore whitespace*/ | ||
case 15: return 36; | ||
break; | ||
case 16: this.begin("INITIAL"); return 18; | ||
case 16: /*ignore whitespace*/ | ||
break; | ||
case 17: this.begin("INITIAL"); return 18; | ||
case 17: this.popState(); return 18; | ||
break; | ||
case 18: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28; | ||
case 18: this.popState(); return 18; | ||
break; | ||
case 19: return 30; | ||
case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28; | ||
break; | ||
case 20: return 30; | ||
break; | ||
case 21: return 29; | ||
case 21: return 30; | ||
break; | ||
case 22: return 33; | ||
case 22: return 29; | ||
break; | ||
case 23: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33; | ||
case 23: return 33; | ||
break; | ||
case 24: return 'INVALID'; | ||
case 24: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33; | ||
break; | ||
case 25: return 5; | ||
case 25: return 'INVALID'; | ||
break; | ||
case 26: return 5; | ||
break; | ||
} | ||
}; | ||
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s/.])/,/^\[.*\]/,/^./,/^$/]; | ||
lexer.conditions = {"mu":{"rules":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"inclusive":false},"INITIAL":{"rules":[0,1,25],"inclusive":true}};return lexer;})() | ||
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^[^\x00]{2,}?(?=(\{\{))/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[\/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s\/.])/,/^\[[^\]]*\]/,/^./,/^$/]; | ||
lexer.conditions = {"mu":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,26],"inclusive":true}};return lexer;})() | ||
parser.lexer = lexer; | ||
@@ -457,0 +463,0 @@ return parser; |
@@ -10,4 +10,6 @@ var Handlebars = require("./base"); | ||
} | ||
this.message = tmp.message; | ||
}; | ||
Handlebars.Exception.prototype = new Error; | ||
Handlebars.Exception.prototype = new Error(); | ||
@@ -14,0 +16,0 @@ // Build out our basic SafeString type |
{ | ||
"name": "handlebars", | ||
"description": "Extension of the Mustache logicless template language", | ||
"version": "1.0.4beta", | ||
"version": "1.0.5beta", | ||
"homepage": "http://www.handlebarsjs.com/", | ||
"keywords": "handlebars mustache template html", | ||
"keywords": [ | ||
"handlebars mustache template html" | ||
], | ||
"repository": { | ||
@@ -15,4 +17,4 @@ "type": "git", | ||
"dependencies": { | ||
"optimist": "~0.3", | ||
"uglify-js": "~1.2" | ||
"optimist": "~0.3", | ||
"uglify-js": "~1.2" | ||
}, | ||
@@ -24,2 +26,2 @@ "devDependencies": {}, | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
73473
1514
316
2