<commit_before>#= require ../namespace

FannyPack.namespace 'FannyPack.View', (View) ->
  class View.Base extends Backbone.View
    application: 'MyApp'
    externalEvents: {}

    initialize: ->
      app = @application

      # Allow creating the eventBus on a namespaced application
      @target = window
      @target = @target[item] ?= {} for item in app.split '.'
      @target.eventBus ?= _.extend({}, Backbone.Events)

    _eventBus: =>
      @target.eventBus

    append: (view) =>
      @$el.append(view.render().$el)

    include: (modules...) ->
      for module in modules
        _.extend @, module

    template: (name, data={}) ->
      JST["#{@application}/templates/#{name}"](data)

    delegateEvents: (events) =>
      super

      for action, handler of @externalEvents
        @_eventBus().on action, _.bind(@[handler], @), @

    stopListening: =>
      for action, handler of @externalEvents
        @_eventBus().off action, null, @

      super

    triggerEvent: (eventName, args...) =>
      # pass all these through
      @_eventBus().trigger eventName, args...<commit_msg>adding support to append multiple views at once<commit_after>#= require ../namespace

FannyPack.namespace 'FannyPack.View', (View) ->
  class View.Base extends Backbone.View
    application: 'MyApp'
    externalEvents: {}

    initialize: ->
      app = @application

      # Allow creating the eventBus on a namespaced application
      @target = window
      @target = @target[item] ?= {} for item in app.split '.'
      @target.eventBus ?= _.extend({}, Backbone.Events)

    _eventBus: =>
      @target.eventBus

    append: (views...) =>
      for view in views
        @$el.append(view.render().$el)

    include: (modules...) ->
      for module in modules
        _.extend @, module

    template: (name, data={}) ->
      JST["#{@application}/templates/#{name}"](data)

    delegateEvents: (events) =>
      super

      for action, handler of @externalEvents
        @_eventBus().on action, _.bind(@[handler], @), @

    stopListening: =>
      for action, handler of @externalEvents
        @_eventBus().off action, null, @

      super

    triggerEvent: (eventName, args...) =>
      # pass all these through
      @_eventBus().trigger eventName, args...
{'fraction_non_alphanumeric': 0.14594356261022928, 'fraction_numerical': 0.0, 'mean_word_length': 2.5397815912636506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '4258465', 'n_tokens_mistral': 676, 'n_tokens_neox': 649, 'n_words': 176}