<commit_before>'use strict';

var utils = require('../utils');

/**
 * Default methods and settings that will be decorated onto
 * each collection.
 */

module.exports = function(app, views, options) {
  if (typeof views.options.renameKey !== 'function') {
    views.option('renameKey', function(key, view) {
      return app.renameKey(key, view);
    });
  }

  // decorate `extendView` onto the collection
  views.extendView = app.extendView.bind(app);

  // bubble up custom collection events, like `app.on('page', ...)`
  var inflection = views.options.inflection;
  if (inflection) {
    views.on(inflection, function() {
      app.emit.bind(app, inflection).apply(app, arguments);
    });
  }

  // bubble up `view` events
  views.on('view', function(view, collectionName, collection) {
    utils.define(view, 'addView', views.addView.bind(views));
    if (views.options.engine) {
      view.engine = views.options.engine;
    }
    app.extendView(view, options);
  });

  views.on('load', function(view, collectionName, collection) {
    app.emit.bind(app, 'view').apply(app, arguments);
    app.handleView('onLoad', view);
  });
};<commit_msg>ensure `view.engine` getter/setter is triggered<commit_after>'use strict';

var utils = require('../utils');

/**
 * Default methods and settings that will be decorated onto
 * each collection.
 */

module.exports = function(app, views, options) {
  if (typeof views.options.renameKey !== 'function') {
    views.option('renameKey', function(key, view) {
      return app.renameKey(key, view);
    });
  }

  // decorate `extendView` onto the collection
  views.extendView = app.extendView.bind(app);

  // bubble up custom collection events, like `app.on('page', ...)`
  var inflection = views.options.inflection;
  if (inflection) {
    views.on(inflection, function() {
      app.emit.bind(app, inflection).apply(app, arguments);
    });
  }

  // bubble up `view` events
  views.on('view', function(view, collectionName, collection) {
    utils.define(view, 'addView', views.addView.bind(views));
    view.engine = views.options.engine || view.engine;
    app.extendView(view, options);
  });

  views.on('load', function(view, collectionName, collection) {
    app.emit.bind(app, 'view').apply(app, arguments);
    app.handleView('onLoad', view);
  });
};
{'fraction_non_alphanumeric': 0.16399826914755516, 'fraction_numerical': 0.0, 'mean_word_length': 3.7183673469387757, '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': '4970339', 'n_tokens_mistral': 721, 'n_tokens_neox': 718, 'n_words': 163}