<commit_before>var AttrMerge = require('./filters/attr_merge');
var AttrRemove = require('./filters/attr_remove');
var Brackets = require('./filters/brackets');
var CodeAttributes = require('./filters/code_attributes');
var ControlFlow = require('./filters/control_flow');
var Controls = require('./filters/controls');
var Ctx = require('./ctx');
var Embeddeds = require('./filters/embedded');
var Engine = require('./engine');
var Escape = require('./filters/escape');
var FastHtml = require('./html/fast');
var Interpolate = require('./filters/interpolate');
var MultiFlattener = require('./filters/multi_flattener');
var Parser = require('./parser');
var Runtime = require('./runtime');
var StaticMerger = require('./filters/static_merger');
var StringGenerator = require('./generators/string');

function Template() {
  this._engine = new Engine();
  this.Embeddeds = Embeddeds;

  this._embedded = new Embeddeds.Embedded();

  this.registerEmbedded('script',     new Embeddeds.Javascript());
  this.registerEmbedded('javascript', new Embeddeds.Javascript({typeAttribute: true}));
  this.registerEmbedded('css',        new Embeddeds.CSS());

  var filters = [
    new Parser(),
    this._embedded,
    new Interpolate(),
    new Brackets(),
    new Controls(),
    new AttrMerge(),
    new CodeAttributes(),
    new AttrRemove(),
    new FastHtml(),
    new Escape(),
    new ControlFlow(),
    new MultiFlattener(),
    new StaticMerger(),
    new StringGenerator()
  ];
  for (var i = 0, f; f = filters[i]; i++) {
    this._engine.use(f);
  }
}

Template.prototype.registerEmbedded = function(name, engine) {
  this._embedded.register(name, engine);
};

Template.prototype.registerEmbeddedFunction = function(name, renderer) {
  var engine = new this.Embeddeds.InterpolateEngine(renderer);
  this.registerEmbedded(name, engine);
};

Template.prototype.eval = function(src, model, options, ctx) {
  ctx = ctx || new Ctx();

  ctx._content = ctx.content.bind(ctx);
  ctx._extend = ctx.extend.bind(ctx);
  ctx._partial = ctx.partial.bind(ctx);
  var rt = Runtime;
  ctx.rt = rt;

  var fn = eval(this.src(src, options))[0];

  return fn.call(model, ctx);
};

Template.prototype.exec = function(src, options, ctx) {
  ctx = ctx || new Ctx();
<commit_msg>Code cleanup<commit_after>var AttrMerge = require('./filters/attr_merge');
var AttrRemove = require('./filters/attr_remove');
var Brackets = require('./filters/brackets');
var CodeAttributes = require('./filters/code_attributes');
var ControlFlow = require('./filters/control_flow');
var Controls = require('./filters/controls');
var Ctx = require('./ctx');
var Embeddeds = require('./filters/embedded');
var Engine = require('./engine');
var Escape = require('./filters/escape');
var FastHtml = require('./html/fast');
var Interpolate = require('./filters/interpolate');
var MultiFlattener = require('./filters/multi_flattener');
var Parser = require('./parser');
var Runtime = require('./runtime');
var StaticMerger = require('./filters/static_merger');
var StringGenerator = require('./generators/string');

function Template() {
  this._engine = new Engine();
  this.Embeddeds = Embeddeds;

  this._embedded = new Embeddeds.Embedded();

  this.registerEmbedded('script',     new Embeddeds.Javascript());
  this.registerEmbedded('javascript', new Embeddeds.Javascript({typeAttribute: true}));
  this.registerEmbedded('css',        new Embeddeds.CSS());

  var filters = this._defaultFilters();
  for (var i = 0, f; f = filters[i]; i++) {
    this._engine.use(f);
  }
}

Template.prototype._defaultFilters = function() {
  return [
    new Parser(),
    this._embedded,
    new Interpolate(),
    new Brackets(),
    new Controls(),
    new AttrMerge(),
    new CodeAttributes(),
    new AttrRemove(),
    new FastHtml(),
    new Escape(),
    new ControlFlow(),
    new MultiFlattener(),
    new StaticMerger(),
    new StringGenerator()
  ];
};

Template.prototype.registerEmbedded = function(name, engine) {
  this._embedded.register(name, engine);
};

Template.prototype.registerEmbeddedFunction = function(name, renderer) {
  var engine = new this.Embeddeds.InterpolateEngine(renderer);
  this.registerEmbedded(name, engine);
};

Template.prototype.eval = function(src, model, options, ctx) {
  ctx = ctx || new Ctx();

  ctx._content = ctx.content.bind(ctx);
  ctx._extend = ctx.extend.bind(ctx);
  ctx._partial = ctx.partial.bind(ctx);
  var rt = Runtime;
  ctx.rt = rt;

  var fn = eval(this.src(src, options))[0];

  return fn.call(model, ctx);
};

Template.prototype.exec = function(src, options, ctx) {
  ctx = ctx || new Ctx();

{'fraction_non_alphanumeric': 0.1644193127446716, 'fraction_numerical': 0.0008699434536755111, 'mean_word_length': 4.378947368421053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4961605', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1383, 'n_words': 321}