<commit_before>var BaseView = (function (_, Backbone) {
  'use strict';

  return Backbone.View.extend({

    channel: null,

    subscriptions: [],

    /**
     * Sets the configuration object and binds render sub-methods.
     */
    initialize: function() {

      if (!this.template &&
        (!this.options.template || !_.isString(this.options.template))) {
        throw new Error('All views must specify their template at creation');
      } else {
        this.template = this.template ? this.template : this.options.template;
      }

      var that = this;

      this.channel = this.options.channel;

      _.bindAll(this, 'beforeRender', 'render', 'afterRender');

      this.render = _.wrap(this.render, function(render) {
        that.beforeRender();
        render();
        that.afterRender();
        return that;
      });
    },

    /**
     * Renders the current view in the specified template.
     */
    render: function() {
      var data = this.options.data,
          templateFunction;

      if (this.model) {
        data = this.model.toJSON();
      }

      var template = _.template(this.template, data);
      this.$el.html(template);
    },

    /**
     * Default action of the view.
     */
    defaultAction: function() {
      this.render();
    },

    /**
     * Subscribe the view to a topic of a channel.
     * @param  {[type]}   topic
     * @param  {Function} callback
     * @return {[type]}
     */
    subscribe: function(topic, callback) {
      var subscription = this.channel.subscribe(topic, callback);
      this.subscriptions.push(subscription);
    },

    /**
     * Publishes data in a postal channel.
     * @param  {[type]} topic
     * @param  {[type]} data
     */
    publish: function(topic, data) {
      this.channel.publish(topic, data);
    },

    /**
     * Removes all the Postal subscriptions of the view.
     */
    unsubscribeAll: function() {
      _.each(this.subscriptions, function(subscription) {
        subscription.unsubscribe();
      });
    },

    /**
     * Disposes the view.
     */
    dispose: function() {
      this.$el.empty();

      if (this.model) {
        this.model.off();
      }

      this.unsubscribeAll();
    },

    beforeRender: function() {},

    afterRender: function() {}
  });

}(_, Backbone));
<commit_msg>Adding back compileTemplate and getTemplate methods.<commit_after>var BaseView = (function (_, Backbone) {
  'use strict';

  return Backbone.View.extend({

    channel: null,

    subscriptions: [],

    /**
     * Sets the configuration object and binds render sub-methods.
     */
    initialize: function() {

      if (!this.template &&
        (!this.options.template || !_.isString(this.options.template))) {
        throw new Error('All views must specify their template at creation');
      } else {
        this.template = this.template ? this.template : this.options.template;
      }

      var that = this;

      this.channel = this.options.channel;

      _.bindAll(this, 'beforeRender', 'render', 'afterRender');

      this.render = _.wrap(this.render, function(render) {
        that.beforeRender();
        render();
        that.afterRender();
        return that;
      });
    },

    /**
     * Renders the current view in the specified template.
     */
    render: function() {
      var data = this.options.data,
          templateFunction;

      if (this.model) {
        data = this.model.toJSON();
      }

      this.compileTemplate();
      this.$el.html(this.getTemplate(data));
    },

    /**
     * This should be redefined by the extended class. It should compile the raw template into
     * a javascript function.
     */
    compileTemplate: function() {
    },

    /**
     * This should be redefined by the extended class. It should take the compiled template and
     * attach the parameters, if any, and return the output.
     * @param  {[object]} data The data that we want to send to the template.
     */
    getTemplate: function(data) {
      return _.template(this.template, data);
    },

    /**
     * Default action of the view.
     */
    defaultAction: function() {
      this.render();
    },

    /**
     * Subscribe the view to a topic of a channel.
     * @param  {[type]}   topic
     * @param  {Function} callback
     * @return {[type]}
     */
    subscribe: function(topic, callback) {
      var subscription = this.channel.subscribe(topic, callback);
      this.subscriptions.push(subscription);
    },

    /**
     * Publishes data in a postal channel.
     * @param  {[type]} topic
     * @param  {[type]} data
     */
    publish: function(topic, data) {
      this.channel.publish(topic, data);
    },

    /**
     * Removes all the Postal subscriptions of the view.
     */
    unsubscribeAll: function() {
      _.each(this.subscriptions, function(subscription) {
        subscription.unsubscribe();
      });
    },

    /**
     * Disposes the view.
     */
    dispose: function() {
      this.$el.empty();

      if (this.model) {
        this.model.off();
      }

      this.unsubscribeAll();
    },

    beforeRender: function() {},

    afterRender: function() {}
  });

}(_, Backbone));

{'fraction_non_alphanumeric': 0.13584760438714644, 'fraction_numerical': 0.0, 'mean_word_length': 2.114439784301977, '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': '6389978', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1450, 'n_words': 380}