diff options
author | Yehuda Katz <wycats@gmail.com> | 2011-10-28 17:39:42 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2011-10-28 17:39:42 -0700 |
commit | 9998d9d9bc2495f2909d9869b765320540987c82 (patch) | |
tree | e079cff5f343bb0c0284d7160fa6af48c741cf0f /lib/handlebars/compiler/compiler.js | |
parent | 924cc3e86cb1c6ccdb7ff125c58060be467e4d70 (diff) | |
download | handlebars.js-9998d9d9bc2495f2909d9869b765320540987c82.zip handlebars.js-9998d9d9bc2495f2909d9869b765320540987c82.tar.gz handlebars.js-9998d9d9bc2495f2909d9869b765320540987c82.tar.bz2 |
Allow subclasses to customize the namespace
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 815348b..39213e7 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -336,6 +336,8 @@ Handlebars.JavaScriptCompiler = function() {}; initializeBuffer: function() { return this.quotedString(""); }, + + namespace: "Handlebars", // END PUBLIC API compile: function(environment, options, context, asObject) { @@ -406,8 +408,9 @@ Handlebars.JavaScriptCompiler = function() {}; var out = []; if (!this.isChild) { - var copies = "helpers = helpers || Handlebars.helpers;"; - if(this.environment.usePartial) { copies = copies + " partials = partials || Handlebars.partials;"; } + var namespace = this.namespace; + var copies = "helpers = helpers || " + namespace + ".helpers;"; + if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; } out.push(copies); } else { out.push(''); @@ -521,7 +524,7 @@ Handlebars.JavaScriptCompiler = function() {}; + " || " + this.nameLookup('depth' + this.lastContext, name, 'context'); } - + toPush += ';'; this.source.push(toPush); } else { @@ -726,7 +729,7 @@ Handlebars.JavaScriptCompiler = function() {}; }; var reservedWords = ("break case catch continue default delete do else finally " + - "for function if in instanceof new return switch this throw " + + "for function if in instanceof new return switch this throw " + "try typeof var void while with null true false").split(" "); var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; |