(function() {
    with( require('apps/framework/app_scope') ) {

        var source = <%= source %>;

        ZendeskApps[<%= name.to_json %>] = ZendeskApps.defineApp(source)
                .reopenClass({ location: <%= location.to_json %> })
                .reopen({
                    assetUrlPrefix: <%= asset_url_prefix.to_json %>,
                    appClassName: <%= app_class_name.to_json %>,
                    author: {
                        name: <%= author[:name].to_json %>,
                        email: <%= author[:email].to_json %>
                    },
                    translations: <%= translations.to_json %>,
                    templates: <%= templates.to_json %>,
                    frameworkVersion: <%= framework_version.to_json %>
                });

    }

    ZendeskApps[<%= name.to_json %>].install({"id": <%= app_id %>, "app_id": <%= app_id %>, "settings": <%= settings.to_json %>});

}());

ZendeskApps.trigger && ZendeskApps.trigger('ready');

(function() {
  with( ZendeskApps.AppScope.create() ) {
    require.modules = {
      <% modules.each do |path, content| %>
        '<%= path %>': function(exports, require, module) {
          <%= content %>
        },
      <% end %>
      eom: undefined
    };

    var source  = <%= source %>;
    var app     = ZendeskApps.defineApp(source)
      .reopenClass({ location: <%= location.to_json %> })
      .reopen({
        assetUrlPrefix: <%= asset_url_prefix.to_json %>,
        appClassName: <%= app_class_name.to_json %>,
        author: {
          name: <%= author[:name].to_json %>,
          email: <%= author[:email].to_json %>
        },
        translations: <%= translations.to_json %>,
        templates: <%= templates.to_json %>,
        frameworkVersion: <%= framework_version.to_json %>,
      });

    ZendeskApps[<%= name.to_json %>] = app;
  }

  ZendeskApps[<%= name.to_json %>].install({"id": <%= app_id %>, "app_id": <%= app_id %>, "settings": <%= settings.to_json %>});
}());

ZendeskApps.trigger && ZendeskApps.trigger('ready');

Load modules, ZAF app scope instance, indentation
Load modules, ZAF app scope instance, indentation
