Remove global Handlebars references

This commit is contained in:
kpdecker
2013-10-09 03:21:21 -07:00
parent b6c9f85d22
commit 4d7124f6bf
3 changed files with 7 additions and 11 deletions
+5 -4
View File
@@ -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;
};
+1 -1
View File
@@ -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; }
}
+1 -6
View File
@@ -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");