<commit_before>'use strict';

/**
 * Module dependencies.
 */

var merge = require('mixin-deep');
var PluginError = require('plugin-error');
var through = require('through2');

/**
 * Expose `render` plugin
 */

module.exports = function(app, config) {
  return function renderPlugin(locals, options) {
    locals = locals || {};
    locals.options = locals.options || {};

    return through.obj(function (file, enc, cb) {
      if (file.isNull()) {
        this.push(file);
        return cb();
      }
      if (file.isStream()) {
        this.emit('error', new PluginError('render-plugin', 'Streaming is not supported.'));
        return cb();
      }

      locals = merge({}, locals, file.locals);
      locals.options = merge({}, app.options, locals.options);

      if (norender(app, file.ext, file, locals)) {
        this.push(file);
        return cb();
      }

      var template = app.getSessionFile(file);
      template.content = file.contents.toString();

      try {
        var stream = this;
        template.render(locals, function (err, content) {
          if (err) {
            stream.emit('error', new PluginError('render-plugin', err));
            cb(err);
            return;
          }
          file.contents = new Buffer(content);
          stream.push(file);
          return cb();
        });

      } catch (err) {
        this.emit('error', new PluginError('render-plugin', err));<commit_msg>renames `getSessionFile` to `getFile`<commit_after>'use strict';

/**
 * Module dependencies.
 */

var merge = require('mixin-deep');
var PluginError = require('plugin-error');
var through = require('through2');

/**
 * Expose `render` plugin
 */

module.exports = function(app, config) {
  return function renderPlugin(locals, options) {
    locals = locals || {};
    locals.options = locals.options || {};

    return through.obj(function (file, enc, cb) {
      if (file.isNull()) {
        this.push(file);
        return cb();
      }
      if (file.isStream()) {
        this.emit('error', new PluginError('render-plugin', 'Streaming is not supported.'));
        return cb();
      }

      locals = merge({}, locals, file.locals);
      locals.options = merge({}, app.options, locals.options);

      if (norender(app, file.ext, file, locals)) {
        this.push(file);
        return cb();
      }

      var template = app.getFile(file);
      template.content = file.contents.toString();

      try {
        var stream = this;
        template.render(locals, function (err, content) {
          if (err) {
            stream.emit('error', new PluginError('render-plugin', err));
            cb(err);
            return;
          }
          file.contents = new Buffer(content);
          stream.push(file);
          return cb();
        });

      } catch (err) {
        this.emit('error', new PluginError('render-plugin', err));
{'fraction_non_alphanumeric': 0.15721739130434784, 'fraction_numerical': 0.0006956521739130435, 'mean_word_length': 2.2981651376146788, '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': '5839270', 'n_tokens_mistral': 837, 'n_tokens_neox': 824, 'n_words': 196}