angular-rails-templates 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Damien MATHIEU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,30 @@
1
+ # Angular Rails Templates
2
+
3
+ Behind the hideous Angular Rails Templates name is hiding a template management system for rails' asset pipeline and AngularJS' template views.
4
+
5
+ Basically: this will precompile your templates into the template cache, to be used by your application.
6
+ It removes the need for ajax calls to get the templates (or for you to manually set them into the dom).
7
+
8
+ ## Usage
9
+
10
+ Add the gem into your Gemfile
11
+
12
+ gem 'angular-rails-templates'
13
+
14
+ Then, in your `application.js` file, require your templates and the internal javascript file:
15
+
16
+ //= require angularjs
17
+ //= require_tree ./path_to_your_templates
18
+ //= require angular-rails-templates
19
+
20
+ The `require angular-rails-templates` **needs** to happen after requiring all your templates. Otherwise, they won't be loaded.
21
+ Your template files can have the extensions **.html** or **.ajs**
22
+
23
+ ## License
24
+
25
+ MIT License. Copyright 2013 Damien Mathieu
26
+
27
+
28
+ ## Authors & contributors
29
+
30
+ * Damien Mathieu <42@dmathieu.com>
@@ -0,0 +1 @@
1
+ angular.module(<%= Rails.configuration.angular_templates.module_name.inspect %> , window.AngularRailsTemplates);
@@ -0,0 +1,7 @@
1
+ module AngularRailsTemplates
2
+
3
+ autoload :Template, 'angular-rails-templates/template'
4
+ autoload :Version, 'angular-rails-templates/version'
5
+ end
6
+
7
+ require 'angular-rails-templates/engine'
@@ -0,0 +1,12 @@
1
+ module AngularRailsTemplates
2
+ class Engine < ::Rails::Engine
3
+ config.angular_templates = ActiveSupport::OrderedOptions.new
4
+ config.angular_templates.module_name = 'templates'
5
+
6
+ config.before_initialize do |app|
7
+ Sprockets::Engines #force autoloading
8
+ Sprockets.register_engine '.ajs', AngularRailsTemplates::Template
9
+ Sprockets.register_engine '.html', AngularRailsTemplates::Template
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'sprockets'
2
+ require 'sprockets/engines'
3
+
4
+ module AngularRailsTemplates
5
+ class Template < Tilt::Template
6
+ def self.default_mime_type
7
+ 'application/javascript'
8
+ end
9
+
10
+ def prepare; end
11
+
12
+ def evaluate(scope, locals, &block)
13
+ key = file.split('/').last
14
+ module_name = "#{configuration.module_name}-#{key.split('.')[0...-1].join('.')}"
15
+
16
+ <<-EOS
17
+ angular.module(#{module_name.inspect}, []).run(function($templateCache) {
18
+ $templateCache.put(#{key.inspect}, #{data.to_json});
19
+ });
20
+
21
+ if (typeof window.AngularRailsTemplates === 'undefined') {
22
+ window.AngularRailsTemplates = [];
23
+ }
24
+ window.AngularRailsTemplates.push(#{module_name.inspect});
25
+ EOS
26
+ end
27
+
28
+ private
29
+ def configuration
30
+ ::Rails.configuration.angular_templates
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module AngularRailsTemplates
2
+ VERSION = '0.0.2'
3
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angular-rails-templates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Damien Mathieu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email:
16
+ - 42@dmathieu.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - LICENSE
23
+ - lib/angular-rails-templates/engine.rb
24
+ - lib/angular-rails-templates/template.rb
25
+ - lib/angular-rails-templates/version.rb
26
+ - lib/angular-rails-templates.rb
27
+ - app/assets/javascripts/angular-rails-templates.js.erb
28
+ homepage: https://github.com/dmathieu/angular-rails-templates
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.8.23
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Use your angular templates with rails' asset pipeline
52
+ test_files: []
53
+ has_rdoc: