angular-rails-templates 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a0ca93253041f7f63902495b7a5a12d9168675c
4
- data.tar.gz: 6e047a80469105cc2b2e9407ac22b13f825efb5f
3
+ metadata.gz: 8ab1b13e51cdc6b7f3e7a3f6159f0479f67c374a
4
+ data.tar.gz: f8561c7c81112d0cf75446bb5a1adcfb9276cfc7
5
5
  SHA512:
6
- metadata.gz: 636a541f11b5f411628fbe4ca377a3b077c9e91b07c4d78bf10fdf0ab1cb27950a35f00642cfef7b68a3e2ee990c1f004d6b3cf8a6cc8f0129526c774d96a021
7
- data.tar.gz: c4324bfee20e0eaf017d5b83969b3bf62e661491bc2f2f89f15dce2e375a12cc0e5ebec2393913416b441c51b5ea602ff27fe7f567973946085f8bf88cf76439
6
+ metadata.gz: d95c383e517ebe42216c61eb19f841290f782c141600c24e35fb7d8f4cc3548c218f1591a26860fda2842ae94afd20ae6f9c966c45e799593cd8be08053d1cdb
7
+ data.tar.gz: bd7f560bef3a1c9cb0aaf27111f14b2a1193ab3e608619d28a3d3428309eee0d78710a83f08343aa0c470937ff64fe0eb53c200f9879a0b12b76d953a2392264
data/README.md CHANGED
@@ -1,9 +1,21 @@
1
- # Angular Rails Templates [![Build Status](https://secure.travis-ci.org/pitr/angular-rails-templates.png?branch=master)](http://travis-ci.org/pitr/angular-rails-templates)
1
+ # Angular Rails Templates
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/angular-rails-templates.png)](http://badge.fury.io/rb/angular-rails-templates)
4
+ [![Coverage Status](https://coveralls.io/repos/github/pitr/angular-rails-templates/badge.svg?branch=master)](https://coveralls.io/github/pitr/angular-rails-templates?branch=master)
5
+ [![Code Climate](https://codeclimate.com/github/pitr/angular-rails-templates/badges/gpa.svg)](https://codeclimate.com/github/pitr/angular-rails-templates)
6
+ [![Issue Stats](http://issuestats.com/github/pitr/angular-rails-templates/badge/pr)](http://issuestats.com/github/pitr/angular-rails-templates)
7
+ [![Issue Stats](http://issuestats.com/github/pitr/angular-rails-templates/badge/issue)](http://issuestats.com/github/pitr/angular-rails-templates)
8
+ [![Stories in Ready](https://badge.waffle.io/pitr/angular-rails-templates.png?label=ready&title=Ready)](https://waffle.io/pitr/angular-rails-templates)
2
9
 
3
10
  Adds your HTML templates into Angular's `$templateCache` using Rails asset pipeline.
4
11
 
5
12
  **IMPORTANT**: for Rails 4.2+ use version 1.0+ of this gem. For Rails 3 - 4.1 use version 0.x
6
13
 
14
+ Branch | Build Status
15
+ ------------|---------
16
+ master | [![Build Status](https://travis-ci.org/pitr/angular-rails-templates.png?branch=master)](https://travis-ci.org/pitr/angular-rails-templates)
17
+ 0-x-stable | [![Build Status](https://travis-ci.org/pitr/angular-rails-templates.png?branch=0-x-stable)](https://travis-ci.org/pitr/angular-rails-templates)
18
+
7
19
  It removes the need for AJAX calls to retrieve the templates (or for you to manually set them into the DOM).
8
20
 
9
21
  ## Usage
@@ -43,8 +55,6 @@ foo.html.haml
43
55
  foo.html.slim
44
56
  ```
45
57
 
46
- Caution: *`.ngslim` is no longer supported!*
47
-
48
58
  Angular Rails Templates will try to load support for the following markups if their gems are present:
49
59
 
50
60
  | Extension | Required gem |
@@ -80,7 +90,7 @@ modals/dialog.html.slim.erb.str => modals/dialog.html # don't do this
80
90
  The templates can then be accessed via `templateUrl` as expected:
81
91
 
82
92
  ```javascript
83
- // Template: app/assets/templates/yourTemplate.html.nghaml
93
+ // Template: app/assets/templates/yourTemplate.html.haml
84
94
  {
85
95
  templateUrl: 'yourTemplate.html'
86
96
  }
@@ -194,7 +204,7 @@ By default this gem looks only at templates with `.html` suffix, eg. `foo.html`
194
204
 
195
205
  ## License
196
206
 
197
- MIT License. Copyright 2015 pitr
207
+ MIT License. Copyright 2016 pitr
198
208
 
199
209
  ## Authors & contributors
200
210
 
@@ -2,6 +2,7 @@ require 'tilt'
2
2
 
3
3
  require 'angular-rails-templates/compact_javascript_escape'
4
4
  require 'angular-rails-templates/processor'
5
+ require 'angular-rails-templates/transformer'
5
6
  require 'angular-rails-templates/engine'
6
7
 
7
8
  module AngularRailsTemplates
@@ -30,7 +30,7 @@ module AngularRailsTemplates
30
30
 
31
31
  # These engines render markup as HTML
32
32
  app.config.angular_templates.markups.each do |ext|
33
- env.register_engine ".#{ext}", Tilt[ext]
33
+ AngularRailsTemplates::Transformer.register(env, ext)
34
34
  end
35
35
  end
36
36
  end
@@ -3,7 +3,7 @@ require 'angular-rails-templates/compact_javascript_escape'
3
3
  module AngularRailsTemplates
4
4
  class Processor
5
5
 
6
- AngularJsTemplateWrapper = Tilt::ERBTemplate.new "#{File.dirname __FILE__}/javascript_template.js.erb"
6
+ AngularJsTemplateWrapper = ::Tilt::ERBTemplate.new "#{File.dirname __FILE__}/javascript_template.js.erb"
7
7
 
8
8
  include CompactJavaScriptEscape
9
9
 
@@ -19,7 +19,7 @@ module AngularRailsTemplates
19
19
  instance.cache_key
20
20
  end
21
21
 
22
- attr_reader :cache_key, :config
22
+ attr_reader :cache_key
23
23
 
24
24
  def config
25
25
  Rails.configuration.angular_templates
@@ -30,7 +30,7 @@ module AngularRailsTemplates
30
30
  end
31
31
 
32
32
  def template_name(name)
33
- path = name.sub /^(#{config.ignore_prefix.join('|')})/, ''
33
+ path = name.sub(/^#{config.ignore_prefix.join('|')}/, '')
34
34
  "#{path}.#{config.extension}"
35
35
  end
36
36
 
@@ -0,0 +1,72 @@
1
+ module AngularRailsTemplates
2
+ #
3
+ # Temporary wrapper, old one is deprecated by Sprockets 4.
4
+ #
5
+ class Transformer
6
+ attr_reader :cache_key
7
+
8
+ def initialize(options = {})
9
+ @cache_key = [self.class.name, VERSION, options].freeze
10
+ end
11
+
12
+ def add_template(ext, template)
13
+ templates[ext] ||= template
14
+ end
15
+
16
+ def call(input)
17
+ filename = input[:filename]
18
+ ext = File.extname(filename).split('.').last
19
+
20
+ return input unless has?(ext)
21
+
22
+ data = input[:data]
23
+ context = input[:environment].context_class.new(input)
24
+
25
+ process(filename, data, context, ext)
26
+ end
27
+
28
+ private
29
+
30
+ def templates
31
+ @templates ||= Hash.new
32
+ end
33
+
34
+ def has?(ext)
35
+ templates.has_key?(ext)
36
+ end
37
+
38
+ def process(filename, data, context, ext)
39
+ data = templates[ext].new(filename) { data }.render(context, {})
40
+ context.metadata.merge(data: data.to_str)
41
+ end
42
+
43
+ class << self
44
+ def instance
45
+ @instance ||= new
46
+ end
47
+
48
+ def cache_key
49
+ instance.cache_key
50
+ end
51
+
52
+ def call(input)
53
+ instance.call(input)
54
+ end
55
+
56
+ def config
57
+ Rails.configuration.angular_templates
58
+ end
59
+
60
+ def register(env, ext)
61
+ if ::Sprockets::VERSION.to_i < 4
62
+ env.register_engine ".#{ext}", ::Tilt[ext] # Legacy Sprockets
63
+ else
64
+ instance.add_template(ext, ::Tilt[ext])
65
+
66
+ env.register_mime_type "text/ng-#{ext}", extensions: [".#{config.extension}.#{ext}"]
67
+ env.register_transformer "text/ng-#{ext}", 'text/ng-html', AngularRailsTemplates::Transformer
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,3 +1,3 @@
1
1
  module AngularRailsTemplates
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-rails-templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damien Mathieu
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-11 00:00:00.000000000 Z
13
+ date: 2016-08-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -36,16 +36,22 @@ dependencies:
36
36
  name: sprockets
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.0'
42
+ - - "<"
43
+ - !ruby/object:Gem::Version
44
+ version: '5'
42
45
  type: :runtime
43
46
  prerelease: false
44
47
  version_requirements: !ruby/object:Gem::Requirement
45
48
  requirements:
46
- - - "~>"
49
+ - - ">="
47
50
  - !ruby/object:Gem::Version
48
51
  version: '3.0'
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
49
55
  - !ruby/object:Gem::Dependency
50
56
  name: tilt
51
57
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +122,7 @@ files:
116
122
  - lib/angular-rails-templates/engine.rb
117
123
  - lib/angular-rails-templates/javascript_template.js.erb
118
124
  - lib/angular-rails-templates/processor.rb
125
+ - lib/angular-rails-templates/transformer.rb
119
126
  - lib/angular-rails-templates/version.rb
120
127
  - vendor/assets/javascripts/angular-rails-templates.js.erb
121
128
  homepage: https://github.com/pitr/angular-rails-templates