Fix test runners under node

This commit is contained in:
kpdecker
2013-10-09 03:22:05 -07:00
parent 4d7124f6bf
commit 3b0a3ca1b2
5 changed files with 34 additions and 24 deletions
+15 -6
View File
@@ -1,15 +1,24 @@
require('./common');
global.Handlebars = require('../../dist/handlebars.runtime');
var _ = require('underscore'),
fs = require('fs'),
vm = require('vm');
var compiler = require('../../lib/handlebars');
global.Handlebars = undefined;
vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.runtime.js'), 'dist/handlebars.runtime.js');
var compiler = require('../../dist/cjs/handlebars/compiler/compiler');
global.CompilerContext = {
compile: function(template, options, env) {
compile: function(template, options) {
var templateSpec = compiler.precompile(template, options);
return Handlebars.template(eval('(' + templateSpec + ')'), env);
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
},
compileWithPartial: function(template, options, env) {
return compiler.compile(template, options);
compileWithPartial: function(template, options) {
// Hack the compiler on to the environment for these specific tests
handlebarsEnv.compile = function(template, options) {
return compiler.compile(template, options, handlebarsEnv);
};
return handlebarsEnv.compile(template, options);
}
};