<commit_before>var Factory = function (dialogs, options) {
  this.dialogs = dialogs;

  this.options = options || {};
  this.config = options.config || {};
  this.templates = options.templates || {};
};

Factory.prototype.createDialog = function (dialog, options) {
  var opts = options || {};
  opts.dialog = dialog;

  var Dialog = this.dialogs.get(dialog.type);

  // add any classname if defined
  if (dialog.className) {
    opts.className = Dialog.prototype.className + ' ' + dialog.className;
  }

  // instanciate dialog
  var view = new Dialog(opts);
  // we need to set the template before rendering the view
  // if no template has been attached to the view search for the main template registry
  if (!view.template) {
    view.template = this.templates[dialog.template];
  }

  return view;
};

Factory.prototype.create = function (slug, options) {
  if (!slug && !this.config.dialogs[slug]) {
    return;
  }

  var dialog = this.config.dialogs[slug];
  return this.createDialog(dialog, options);
};

Factory.prototype.render = function (region, slug, options) {
  if (!region) {
    return;
  }

  var dialog = this.create(slug, options);

  if (!dialog) {
    return false;
  }

  region.show(dialog);
};<commit_msg>feat(factory): return dialog on render<commit_after>var Factory = function (dialogs, options) {
  this.dialogs = dialogs;

  this.options = options || {};
  this.config = options.config || {};
  this.templates = options.templates || {};
};

Factory.prototype.createDialog = function (dialog, options) {
  var opts = options || {};
  opts.dialog = dialog;

  var Dialog = this.dialogs.get(dialog.type);

  // add any classname if defined
  if (dialog.className) {
    opts.className = Dialog.prototype.className + ' ' + dialog.className;
  }

  // instanciate dialog
  var view = new Dialog(opts);
  // we need to set the template before rendering the view
  // if no template has been attached to the view search for the main template registry
  if (!view.template) {
    view.template = this.templates[dialog.template];
  }

  return view;
};

Factory.prototype.create = function (slug, options) {
  if (!slug && !this.config.dialogs[slug]) {
    return;
  }

  var dialog = this.config.dialogs[slug];
  return this.createDialog(dialog, options);
};

Factory.prototype.render = function (region, slug, options) {
  if (!region) {
    return;
  }

  var dialog = this.create(slug, options);

  if (!dialog) {
    return false;
  }

  region.show(dialog);

  return dialog;
};
{'fraction_non_alphanumeric': 0.13482249700837654, 'fraction_numerical': 0.0, 'mean_word_length': 3.415492957746479, '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': '1839985', 'n_tokens_mistral': 768, 'n_tokens_neox': 756, 'n_words': 212}