angular-rails-templates 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ecc69424ed5a85900c3a2f5bd80fad58a3748c1
4
- data.tar.gz: 31ad8c9b9a222e492b06fb599c7c581066839943
3
+ metadata.gz: 95ece303d7645e28620e1d23962f25cc83b8bbd6
4
+ data.tar.gz: 027e3a27b77c858645ca73cddf819358bd625fb2
5
5
  SHA512:
6
- metadata.gz: c94cd4601f52c33386d3af9ad795aee21209fc55ec4c6095bf47cd0a2a7569ce16c3ff97323f5bc57b2a95b83abb32557916f97783d8a31fb944e0d5738c71bd
7
- data.tar.gz: 7584688e9ff567b218d16e8357dcf958c4ab09f488804b85ae41502a9f9fef8cbb0f660001214aa6a9e0a54c989b8afca0b26d2a541996da1b30c18764eeaa04
6
+ metadata.gz: 70acb2c79fa6ff46f32ddab5262c2213fd5890015405b983b63627c3dfb2f6c86984c15d85fb8e1f6da62b3d0434752395ddc8e919f0f4519bb455ce63f92163
7
+ data.tar.gz: bf103ce7edd782659b62ae11d4c4cc09ae550140d4b5d51d2e47355c9ad22cecc5de074ada646e2c3f791cda875d9dc015ba8e8ff02a242475fbdc7cb7bc88f9
data/README.md CHANGED
@@ -92,7 +92,7 @@ Here are their default values:
92
92
  ```ruby
93
93
  # config/application.rb
94
94
  config.angular_templates.module_name = 'templates'
95
- config.angular_templates.ignore_prefix = 'templates/'
95
+ config.angular_templates.ignore_prefix = %w(templates/)
96
96
  config.angular_templates.markups = %w(erb str haml slim md)
97
97
  config.angular_templates.htmlcompressor = false
98
98
  ```
@@ -114,9 +114,9 @@ Although it is not recommended, you can set `module_name` to the name of your ma
114
114
 
115
115
  `ignore_prefix` will be stripped from the beginning of the `templateUrl` it reports to angularjs.
116
116
 
117
- Since the default ignore_prefix is `templates/`, any templates placed under `app/assets/javascripts/templates` will automatically have short names. If your templates are not in this location, you will need to use the full path to the template.
117
+ Since the default ignore_prefix is [`templates/`], any templates placed under `app/assets/javascripts/templates` will automatically have short names. If your templates are not in this location, you will need to use the full path to the template.
118
118
 
119
- You can set `config.angular_templates.ignore_prefix` to change the default ignore prefix. Default is `templates/`.
119
+ You can set `config.angular_templates.ignore_prefix` to change the default ignore prefix. Default is [`templates/`].
120
120
 
121
121
 
122
122
  ``` javascript
@@ -4,24 +4,26 @@ module AngularRailsTemplates
4
4
  class Engine < ::Rails::Engine
5
5
  config.angular_templates = ActiveSupport::OrderedOptions.new
6
6
  config.angular_templates.module_name = 'templates'
7
- config.angular_templates.ignore_prefix = 'templates/'
7
+ config.angular_templates.ignore_prefix = ['templates/']
8
8
  config.angular_templates.markups = []
9
9
  config.angular_templates.htmlcompressor = false
10
10
 
11
- # try loading common markups
12
- %w(erb haml liquid md radius slim str textile wiki).
13
- each do |ext|
14
- begin
15
- silence_warnings do
16
- config.angular_templates.markups << ext if Tilt[ext]
11
+ config.before_configuration do |app|
12
+ # try loading common markups
13
+ %w(erb haml liquid md radius slim str textile wiki).
14
+ each do |ext|
15
+ begin
16
+ silence_warnings do
17
+ config.angular_templates.markups << ext if Tilt[ext]
18
+ end
19
+ rescue LoadError
20
+ # They don't have the required library required. Oh well.
17
21
  end
18
- rescue LoadError
19
- # They don't have the required library required. Oh well.
20
22
  end
21
23
  end
22
24
 
23
25
 
24
- config.before_initialize do |app|
26
+ initializer 'angular-rails-templates' do |app|
25
27
  if app.config.assets
26
28
  require 'sprockets'
27
29
  require 'sprockets/engines' # load sprockets for Rails 3
@@ -44,11 +46,11 @@ module AngularRailsTemplates
44
46
  end
45
47
  end
46
48
 
47
- Sprockets.register_engine ".#{ext}", mimeless_engine
49
+ app.assets.register_engine ".#{ext}", mimeless_engine
48
50
  end
49
51
 
50
52
  # This engine wraps the HTML into JS
51
- Sprockets.register_engine '.html', AngularRailsTemplates::Template
53
+ app.assets.register_engine '.html', AngularRailsTemplates::Template
52
54
  end
53
55
 
54
56
  # Sprockets Cache Busting
@@ -59,5 +61,13 @@ module AngularRailsTemplates
59
61
  Digest::MD5.hexdigest("#{VERSION}-#{app.config.angular_templates}")
60
62
  ].join '-'
61
63
  end
64
+
65
+
66
+ config.after_initialize do |app|
67
+ # Ensure ignore_prefix can be passed as a String or Array
68
+ if app.config.angular_templates.ignore_prefix.is_a? String
69
+ app.config.angular_templates.ignore_prefix = Array(app.config.angular_templates.ignore_prefix)
70
+ end
71
+ end
62
72
  end
63
73
  end
@@ -29,7 +29,7 @@ module AngularRailsTemplates
29
29
  private
30
30
 
31
31
  def logical_template_path(scope)
32
- path = scope.logical_path.sub /^#{configuration.ignore_prefix}/, ''
32
+ path = scope.logical_path.sub /^(#{configuration.ignore_prefix.join('|')})/, ''
33
33
  "#{path}.html"
34
34
  end
35
35
 
@@ -1,3 +1,3 @@
1
1
  module AngularRailsTemplates
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
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: 0.1.2
4
+ version: 0.1.3
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: 2014-05-20 00:00:00.000000000 Z
13
+ date: 2014-07-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties