Provide Handlebars.noConflict implementation

Allows for users who are loading via a global pattern to avoid conflicting with other instances of the library.

Fixes #887
This commit is contained in:
kpdecker
2014-11-26 07:48:45 -06:00
parent 617dd57162
commit c4b3c901a5
5 changed files with 40 additions and 2 deletions
+3 -1
View File
@@ -5,7 +5,7 @@ var _ = require('underscore'),
fs = require('fs'),
vm = require('vm');
global.Handlebars = undefined;
global.Handlebars = 'no-conflict';
vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.runtime.js'), 'dist/handlebars.runtime.js');
var parse = require('../../dist/cjs/handlebars/compiler/base').parse;
@@ -13,6 +13,8 @@ var compiler = require('../../dist/cjs/handlebars/compiler/compiler');
var JavaScriptCompiler = require('../../dist/cjs/handlebars/compiler/javascript-compiler')['default'];
global.CompilerContext = {
browser: true,
compile: function(template, options) {
// Hack the compiler on to the environment for these specific tests
handlebarsEnv.precompile = function(template, options) {