diff --git a/app/assets/javascripts/angular-rails-templates.js.erb b/app/assets/javascripts/angular-rails-templates.js.erb index 661f575..e69de29 100644 --- a/app/assets/javascripts/angular-rails-templates.js.erb +++ b/app/assets/javascripts/angular-rails-templates.js.erb @@ -1 +0,0 @@ -angular.module(<%= Rails.configuration.angular_templates.module_name.inspect %> , window.AngularRailsTemplates); diff --git a/lib/angular-rails-templates/template.rb b/lib/angular-rails-templates/template.rb index 18d2e61..4fc2455 100644 --- a/lib/angular-rails-templates/template.rb +++ b/lib/angular-rails-templates/template.rb @@ -14,14 +14,12 @@ def evaluate(scope, locals, &block) logical_template_path = logical_template_path(scope) <<-EOS -angular.module(#{module_name.inspect}, []).run(["$templateCache",function($templateCache) { + +window.AngularRailsTemplates || (window.AngularRailsTemplates = angular.module(#{module_name.inspect}, [])); + +window.AngularRailsTemplates.run(["$templateCache",function($templateCache) { $templateCache.put(#{logical_template_path.inspect}, #{data.to_json}); }]); - -if (typeof window.AngularRailsTemplates === 'undefined') { - window.AngularRailsTemplates = []; -} -window.AngularRailsTemplates.push(#{module_name.inspect}); EOS end