Fix up the compilation process
This commit is contained in:
+16
-15
@@ -1,17 +1,16 @@
|
||||
if(exports) {
|
||||
var Handlebars = {};
|
||||
var Handlebars = {};
|
||||
|
||||
Handlebars.AST = require("handlebars/ast").AST;
|
||||
Handlebars.HandlebarsLexer = require("handlebars/handlebars_lexer").Lexer;
|
||||
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
|
||||
Handlebars.Parser = require("handlebars/parser").parser;
|
||||
Handlebars.Runtime = require("handlebars/runtime").Runtime;
|
||||
Handlebars.Utils = require("handlebars/utils").Utils;
|
||||
Handlebars.SafeString = require("handlebars/utils").SafeString;
|
||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
||||
} else {
|
||||
Handlebars.Parser = handlebars;
|
||||
}
|
||||
Handlebars.AST = require("handlebars/ast").AST;
|
||||
Handlebars.HandlebarsLexer = require("handlebars/handlebars_lexer").Lexer;
|
||||
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
|
||||
var handlebars = require("handlebars/parser").parser;
|
||||
Handlebars.Runtime = require("handlebars/runtime").Runtime;
|
||||
Handlebars.Utils = require("handlebars/utils").Utils;
|
||||
Handlebars.SafeString = require("handlebars/utils").SafeString;
|
||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.Parser = handlebars;
|
||||
|
||||
Handlebars.parse = function(string) {
|
||||
Handlebars.Parser.yy = Handlebars.AST;
|
||||
@@ -28,8 +27,10 @@ Handlebars.compile = function(string) {
|
||||
|
||||
return function(context, fallback) {
|
||||
var runtime = new Handlebars.Runtime(context, fallback);
|
||||
return runtime.accept(ast);
|
||||
runtime.accept(ast);
|
||||
return runtime.buffer;
|
||||
}
|
||||
}
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) { exports.Handlebars = Handlebars }
|
||||
exports.Handlebars = Handlebars
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
if(exports) { var Handlebars = {} }
|
||||
var Handlebars = {};
|
||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
(function() {
|
||||
|
||||
Handlebars.AST = {};
|
||||
@@ -77,7 +79,6 @@ if(exports) { var Handlebars = {} }
|
||||
}
|
||||
|
||||
})();
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) {
|
||||
exports.AST = Handlebars.AST;
|
||||
}
|
||||
exports.AST = Handlebars.AST;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
if(exports) {
|
||||
var Handlebars = {};
|
||||
Handlebars.Lexer = require("handlebars/jison_ext").Lexer
|
||||
}
|
||||
var Handlebars = {};
|
||||
Handlebars.Lexer = require("handlebars/jison_ext").Lexer
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.HandlebarsLexer = function() {
|
||||
this.state = "CONTENT";
|
||||
};
|
||||
@@ -122,5 +121,6 @@ Handlebars.HandlebarsLexer.prototype.lex = function() {
|
||||
return "CONTENT"
|
||||
}
|
||||
};
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) { exports.Lexer = Handlebars.HandlebarsLexer; }
|
||||
exports.Lexer = Handlebars.HandlebarsLexer;
|
||||
|
||||
+18
-18
@@ -1,5 +1,6 @@
|
||||
if(exports) { var Handlebars = {} }
|
||||
var Handlebars = {};
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.Lexer = function() {};
|
||||
|
||||
Handlebars.Lexer.prototype = {
|
||||
@@ -18,34 +19,34 @@ Handlebars.Lexer.prototype = {
|
||||
|
||||
getchar: function(n) {
|
||||
n = n || 1;
|
||||
var chars = "", char = "";
|
||||
var chars = "", chr = "";
|
||||
|
||||
for(var i=0; i<n; i++) {
|
||||
char = this.input[0];
|
||||
chars += char;
|
||||
this.yytext += char;
|
||||
chr = this.input[0];
|
||||
chars += chr;
|
||||
this.yytext += chr;
|
||||
this.yyleng++;
|
||||
|
||||
this.matched += char;
|
||||
this.match += char;
|
||||
this.matched += chr;
|
||||
this.match += chr;
|
||||
|
||||
if(char === "\n") this.yylineno++;
|
||||
if(chr === "\n") this.yylineno++;
|
||||
|
||||
this.input = this.input.slice(1);
|
||||
}
|
||||
return char;
|
||||
return chr;
|
||||
},
|
||||
|
||||
readchar: function(n, ignore) {
|
||||
n = n || 1;
|
||||
var char;
|
||||
var chr;
|
||||
|
||||
for(var i=0; i<n; i++) {
|
||||
char = this.input[i];
|
||||
if(char === "\n") this.yylineno++;
|
||||
chr = this.input[i];
|
||||
if(chr === "\n") this.yylineno++;
|
||||
|
||||
this.matched += char;
|
||||
this.match += char;
|
||||
this.matched += chr;
|
||||
this.match += chr;
|
||||
if(ignore) { this.readchars++; }
|
||||
}
|
||||
|
||||
@@ -87,8 +88,7 @@ Handlebars.Visitor.prototype = {
|
||||
return this[object.type](object);
|
||||
}
|
||||
}
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) {
|
||||
exports.Lexer = Handlebars.Lexer;
|
||||
exports.Visitor = Handlebars.Visitor;
|
||||
}
|
||||
exports.Lexer = Handlebars.Lexer;
|
||||
exports.Visitor = Handlebars.Visitor;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
if(exports) {
|
||||
var Handlebars = {};
|
||||
Handlebars.Visitor = require("handlebars/jison_ext").Visitor
|
||||
}
|
||||
var Handlebars = {};
|
||||
Handlebars.Visitor = require("handlebars/jison_ext").Visitor
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.PrintVisitor = function() { this.padding = 0; };
|
||||
Handlebars.PrintVisitor.prototype = new Handlebars.Visitor;
|
||||
|
||||
@@ -109,7 +108,6 @@ Handlebars.PrintVisitor.prototype.content = function(content) {
|
||||
Handlebars.PrintVisitor.prototype.comment = function(comment) {
|
||||
return this.pad("{{! '" + comment.comment + "' }}");
|
||||
}
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) {
|
||||
exports.PrintVisitor = Handlebars.PrintVisitor;
|
||||
}
|
||||
exports.PrintVisitor = Handlebars.PrintVisitor;
|
||||
|
||||
+37
-29
@@ -1,12 +1,20 @@
|
||||
if(exports) {
|
||||
var inspect = function(obj) {
|
||||
require("sys").print(require("sys").inspect(obj) + "\n");
|
||||
};
|
||||
var Handlebars = {};
|
||||
Handlebars.AST = require("handlebars/ast");
|
||||
Handlebars.Visitor = require("handlebars/jison_ext").Visitor;
|
||||
}
|
||||
var inspect = function(obj) {
|
||||
require("sys").print(require("sys").inspect(obj) + "\n");
|
||||
};
|
||||
|
||||
var Handlebars = {};
|
||||
|
||||
Handlebars.AST = require("handlebars/ast").AST;
|
||||
Handlebars.HandlebarsLexer = require("handlebars/handlebars_lexer").Lexer;
|
||||
Handlebars.Visitor = require("handlebars/jison_ext").Visitor;
|
||||
Handlebars.PrintVisitor = require("handlebars/printer").PrintVisitor;
|
||||
Handlebars.Parser = require("handlebars/parser").parser;
|
||||
Handlebars.Runtime = require("handlebars/runtime").Runtime;
|
||||
Handlebars.Utils = require("handlebars/utils").Utils;
|
||||
Handlebars.SafeString = require("handlebars/utils").SafeString;
|
||||
Handlebars.Exception = require("handlebars/utils").Exception;
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
// A Context wraps data, and makes it possible to extract a
|
||||
// new Context given a path. For instance, if the data
|
||||
// is { person: { name: "Alan" } }, a Context wrapping
|
||||
@@ -21,10 +29,7 @@ Handlebars.Context.prototype = {
|
||||
|
||||
// Make a shallow copy of the Context
|
||||
clone: function() {
|
||||
var context = new Handlebars.Context();
|
||||
context.data = this.data;
|
||||
context.fallback = this.fallback;
|
||||
return context;
|
||||
return new Handlebars.Context(this.data, this.fallback);
|
||||
},
|
||||
|
||||
// Search for an object inside the Context's data. The
|
||||
@@ -94,19 +99,21 @@ Handlebars.Runtime.prototype = {
|
||||
var statements = program.statements;
|
||||
|
||||
for(var i=0, l=statements.length; i<l; i++) {
|
||||
this.accept(statements[i]);
|
||||
var statement = statements[i];
|
||||
this[statement.type](statement);
|
||||
}
|
||||
|
||||
return this.buffer;
|
||||
},
|
||||
|
||||
mustache: function(mustache) {
|
||||
var idObj = this.accept(mustache.id);
|
||||
var idObj = this.ID(mustache.id);
|
||||
var params = mustache.params;
|
||||
var buf;
|
||||
|
||||
for(var i=0, l=params.length; i<l; i++) {
|
||||
params[i] = this.accept(params[i]).data;
|
||||
var param = params[i];
|
||||
params[i] = this[param.type](param).data;
|
||||
}
|
||||
|
||||
if(toString.call(idObj.data) === "[object Function]") {
|
||||
@@ -125,12 +132,12 @@ Handlebars.Runtime.prototype = {
|
||||
var mustache = block.mustache,
|
||||
id = mustache.id;
|
||||
|
||||
var idObj = this.accept(mustache.id),
|
||||
var idObj = this.ID(mustache.id),
|
||||
data = idObj.data;
|
||||
|
||||
if(toString.call(data) !== "[object Function]") {
|
||||
params = [data];
|
||||
data = this.context.evaluate({depth: 0, parts: ["helperMissing"]}, this.stack).data;
|
||||
data = this.context.fallback.helperMissing;
|
||||
} else {
|
||||
params = this.evaluateParams(mustache.params);
|
||||
}
|
||||
@@ -148,7 +155,7 @@ Handlebars.Runtime.prototype = {
|
||||
},
|
||||
|
||||
partial: function(partial) {
|
||||
var partials = this.context.evaluate({depth: 0, parts: ["partials"]}, this.stack).data || {};
|
||||
var partials = this.context.fallback.partials || {};
|
||||
var id = partial.id.original;
|
||||
|
||||
var partialBody = partials[partial.id.original];
|
||||
@@ -165,12 +172,12 @@ Handlebars.Runtime.prototype = {
|
||||
}
|
||||
|
||||
if(partial.context) {
|
||||
var context = this.accept(partial.context);
|
||||
var context = this.ID(partial.context);
|
||||
} else {
|
||||
var context = this.context;
|
||||
}
|
||||
var runtime = new Handlebars.Runtime(context, this.context.fallback, this.stack.slice(0));
|
||||
this.buffer = this.buffer + runtime.accept(program);
|
||||
this.buffer = this.buffer + runtime.program(program);
|
||||
},
|
||||
|
||||
not: function(context, fn) {
|
||||
@@ -183,7 +190,7 @@ Handlebars.Runtime.prototype = {
|
||||
id = mustache.id,
|
||||
not;
|
||||
|
||||
var idObj = this.accept(id),
|
||||
var idObj = this.ID(id),
|
||||
data = idObj.data,
|
||||
isInverse = Handlebars.Utils.isEmpty(data);
|
||||
|
||||
@@ -213,12 +220,15 @@ Handlebars.Runtime.prototype = {
|
||||
comment: function() {},
|
||||
|
||||
evaluateParams: function(params) {
|
||||
var ret = [];
|
||||
|
||||
for(var i=0, l=params.length; i<l; i++) {
|
||||
params[i] = this.accept(params[i]).data;
|
||||
var param = params[i];
|
||||
ret[i] = this[param.type](param).data;
|
||||
}
|
||||
|
||||
if(params.length === 0) { params = [this.wrapContext()]; }
|
||||
return params;
|
||||
if(ret.length === 0) { ret = [this.wrapContext()]; }
|
||||
return ret;
|
||||
},
|
||||
|
||||
wrapContext: function() {
|
||||
@@ -246,14 +256,12 @@ Handlebars.Runtime.prototype = {
|
||||
return function(context) {
|
||||
if(context && context.isWrappedContext) { context = context.__data__; }
|
||||
var runtime = new Handlebars.Runtime(context, fallback, stack);
|
||||
runtime.accept(program);
|
||||
runtime.program(program);
|
||||
return runtime.buffer;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) {
|
||||
exports.Runtime = Handlebars.Runtime;
|
||||
}
|
||||
|
||||
exports.Runtime = Handlebars.Runtime;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
if(exports) {
|
||||
var Handlebars = {};
|
||||
}
|
||||
var Handlebars = {};
|
||||
|
||||
// BEGIN(BROWSER)
|
||||
Handlebars.Exception = function(message) {
|
||||
this.message = message;
|
||||
};
|
||||
@@ -59,9 +58,8 @@ Handlebars.Utils = {
|
||||
}
|
||||
}
|
||||
}
|
||||
// END(BROWSER)
|
||||
|
||||
if(exports) {
|
||||
exports.Utils = Handlebars.Utils;
|
||||
exports.SafeString = Handlebars.SafeString;
|
||||
exports.Exception = Handlebars.Exception;
|
||||
}
|
||||
exports.Utils = Handlebars.Utils;
|
||||
exports.SafeString = Handlebars.SafeString;
|
||||
exports.Exception = Handlebars.Exception;
|
||||
|
||||
Reference in New Issue
Block a user