summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/handlebars.js9
-rw-r--r--lib/handlebars/ast.js3
-rw-r--r--lib/handlebars/runtime.js6
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/handlebars.js b/lib/handlebars.js
index ca080ca..5d53ed5 100644
--- a/lib/handlebars.js
+++ b/lib/handlebars.js
@@ -20,4 +20,13 @@ Handlebars.print = function(ast) {
return new Handlebars.PrintVisitor().accept(ast);
}
+Handlebars.compile = function(string) {
+ var ast = Handlebars.parse(string);
+
+ return function(context, fallback) {
+ var runtime = new Handlebars.Runtime(context, fallback);
+ return runtime.accept(ast);
+ }
+}
+
if(exports) { exports.Handlebars = Handlebars }
diff --git a/lib/handlebars/ast.js b/lib/handlebars/ast.js
index ca9ffd1..fdd37a3 100644
--- a/lib/handlebars/ast.js
+++ b/lib/handlebars/ast.js
@@ -32,7 +32,6 @@ Handlebars.AST.ContentNode = function(string) {
Handlebars.AST.IdNode = function(parts) {
this.type = "ID"
- this.parts = parts;
var dig = [], depth = 0;
@@ -44,7 +43,7 @@ Handlebars.AST.IdNode = function(parts) {
else { dig.push(part) }
}
- this.dig = dig;
+ this.parts = dig;
this.depth = depth;
}
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index 1e676ea..ad1ced6 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -96,11 +96,13 @@ Handlebars.Runtime.prototype = {
for(var i=0, l=statements.length; i<l; i++) {
this.accept(statements[i]);
}
+
+ return this.buffer;
},
mustache: function(mustache) {
var idObj = this.accept(mustache.id);
- var params = this.evaluateParams(mustache.params);
+ var params = mustache.params;
for(var i=0, l=params.length; i<l; i++) {
params[i] = this.accept(params[i]).data;
@@ -137,6 +139,8 @@ Handlebars.Runtime.prototype = {
this.buffer += content.string;
},
+ comment: function() {},
+
evaluateParams: function(params) {
for(var i=0, l=params.length; i<l; i++) {
params[i] = this.accept(params[i]).data;