Code coverage report for spec/env/browser.js

Statements: 46.15% (6 / 13)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 46.15% (6 / 13)      Ignored: none     

All files » spec/env/ » browser.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1   1       1 1   1                   1                
/*global handlebarsEnv */
require('./common');
 
var _ = require('underscore'),
    fs = require('fs'),
    vm = require('vm');
 
global.Handlebars = undefined;
vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.js'), 'dist/handlebars.js');
 
global.CompilerContext = {
  compile: function(template, options) {
    var templateSpec = handlebarsEnv.precompile(template, options);
    return handlebarsEnv.template(safeEval(templateSpec));
  },
  compileWithPartial: function(template, options) {
    return handlebarsEnv.compile(template, options);
  }
};
 
function safeEval(templateSpec) {
  try {
    return eval('(' + templateSpec + ')');
  } catch (err) {
    console.error(templateSpec);
    throw err;
  }
}