summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/handlebars/base.js9
-rw-r--r--lib/handlebars/compiler/ast.js2
-rw-r--r--spec/builtins.js7
3 files changed, 7 insertions, 11 deletions
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js
index c83144a..a4acef9 100644
--- a/lib/handlebars/base.js
+++ b/lib/handlebars/base.js
@@ -3,8 +3,6 @@
import { extend, isEmpty } from "./utils";
import Exception from "./exception";
-var K = function() { return this; };
-
export var VERSION = "1.0.0";
export var COMPILER_REVISION = 4;
@@ -44,6 +42,9 @@ export function HandlebarsEnvironment(helpers, partials) {
HandlebarsEnvironment.prototype = {
constructor: HandlebarsEnvironment,
+ logger: logger,
+ log: log,
+
registerHelper: function(name, fn, inverse) {
if (toString.call(name) === objectType) {
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
@@ -148,7 +149,7 @@ function registerDefaultHelpers(instance) {
instance.registerHelper('log', function(context, options) {
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
- Handlebars.log(level, context);
+ instance.log(level, context);
});
}
@@ -174,6 +175,6 @@ export function log(level, obj) { logger.log(level, obj); }
export var createFrame = function(object) {
var obj = {};
- Handlebars.Utils.extend(obj, object);
+ extend(obj, object);
return obj;
};
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index e4e8049..336492d 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -71,7 +71,7 @@ export function IdNode(parts) {
original += (parts[i].separator || '') + part;
if (part === ".." || part === "." || part === "this") {
- if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + original); }
+ if (dig.length > 0) { throw new Exception("Invalid path: " + original); }
else if (part === "..") { depth++; }
else { this.isScoped = true; }
}
diff --git a/spec/builtins.js b/spec/builtins.js
index 7c3e012..c678964 100644
--- a/spec/builtins.js
+++ b/spec/builtins.js
@@ -1,10 +1,5 @@
/*global CompilerContext, shouldCompileTo, compileWithPartials */
describe('builtin helpers', function() {
- var originalLog = Handlebars.log;
- afterEach(function() {
- Handlebars.log = originalLog;
- });
-
describe('#if', function() {
it("if", function() {
var string = "{{#if goodbye}}GOODBYE {{/if}}cruel {{world}}!";
@@ -130,7 +125,7 @@ describe('builtin helpers', function() {
var hash = { blah: "whee" };
var levelArg, logArg;
- Handlebars.log = function(level, arg){ levelArg = level, logArg = arg; };
+ handlebarsEnv.log = function(level, arg){ levelArg = level, logArg = arg; };
shouldCompileTo(string, hash, "", "log should not display");
equals(1, levelArg, "should call log with 1");