<commit_before>// go.components.templating
// =========================
// Components the client-side templates used in Go.

(function(exports) {
  var maybeByName = go.utils.maybeByName;

  var Template = Backbone.View.extend({
    jst: _.template(''),

    partials: {},

    data: {},

    initialize: function(options) {
      if (options.data) { this.data = options.data; }

      if (options.jst) { this.jst = options.jst; }
      this.partials = _({}).extend(this.partials, options.partials || {});
    },

    renderPartial: function(name) {
      var partial = this.partials[name],
          $el;

      if (partial instanceof Backbone.View) {
        partial.render();
        $el = partial.$el;
      } else {
        $el = $(maybeByName(partial)(_(this).result('data')));
      }

      $el.attr('data-partial', name);
      this.$('[data-partial="' + name + '"]').replaceWith($el);
      return this;
    },

    render: function() {
      this.$el.html(this.jst(_(this).result('data')));
      _(this.partials).keys().forEach(this.renderPartial, this);
      return this;
    }
  });

  _.extend(exports, {
    Template: Template
  });
})(go.components.templating = {});<commit_msg>Allow Template.p.jst to be an object referenced by name<commit_after>// go.components.templating
// =========================
// Components the client-side templates used in Go.

(function(exports) {
  var maybeByName = go.utils.maybeByName;

  var Template = Backbone.View.extend({
    jst: _.template(''),

    partials: {},

    data: {},

    initialize: function(options) {
      if (options.data) { this.data = options.data; }

      if (options.jst) { this.jst = options.jst; }
      this.partials = _({}).extend(this.partials, options.partials || {});
    },

    renderPartial: function(name) {
      var partial = this.partials[name],
          $el;

      if (partial instanceof Backbone.View) {
        partial.render();
        $el = partial.$el;
      } else {
        $el = $(maybeByName(partial)(_(this).result('data')));
      }

      $el.attr('data-partial', name);
      this.$('[data-partial="' + name + '"]').replaceWith($el);
      return this;
    },

    render: function() {
      this.$el.html(maybeByName(this.jst)(_(this).result('data')));
      _(this.partials).keys().forEach(this.renderPartial, this);
      return this;
    }
  });

  _.extend(exports, {
    Template: Template
  });
})(go.components.templating = {});
{'fraction_non_alphanumeric': 0.19697588884348183, 'fraction_numerical': 0.0, 'mean_word_length': 2.737404580152672, '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': '3174', 'n_tokens_mistral': 784, 'n_tokens_neox': 763, 'n_words': 142}