angular-rails-templates 1.0.0.beta1 → 1.0.0.beta2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbefeac21102c52f7dea590354b3c604eb7bfb25
|
4
|
+
data.tar.gz: 23ef898639c6e0075d73907deb26097ad133c3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8718dee198ddb5d6f0b901c83cd9ea9f785b8baffc8ec9d6b67abe3f2ce251651f42bc02a18cc30b0a046c956495ae832aa2e90e9ce6be2df6b6fdf5be14c5d3
|
7
|
+
data.tar.gz: f83814289810fa589af5dacde87a288ddae086d21b887953cab5fe70dab68ae6e15ec8eca4718bb666d88c898a762ea79d50413b5866cdd5e69bb47662e9f355
|
data/README.md
CHANGED
@@ -105,8 +105,9 @@ Here are their default values:
|
|
105
105
|
# config/application.rb
|
106
106
|
config.angular_templates.module_name = 'templates'
|
107
107
|
config.angular_templates.ignore_prefix = %w(templates/)
|
108
|
-
config.angular_templates.inside_paths = [
|
108
|
+
config.angular_templates.inside_paths = ['app/assets']
|
109
109
|
config.angular_templates.markups = %w(erb str haml slim md)
|
110
|
+
config.angular_templates.extension = 'html'
|
110
111
|
```
|
111
112
|
|
112
113
|
### Configuration Option: `module_name`
|
@@ -187,6 +188,10 @@ config.angular_templates.markups.push 'nghaml'
|
|
187
188
|
```
|
188
189
|
Note: You would still need to use `foo`**`.html`**`.nghaml`
|
189
190
|
|
191
|
+
### Configuration Option: `extension`
|
192
|
+
|
193
|
+
By default this gem looks only at templates with `.html` suffix, eg. `foo.html` or `foo.html.haml`. This extension allows you to change that to another extension
|
194
|
+
|
190
195
|
## License
|
191
196
|
|
192
197
|
MIT License. Copyright 2015 pitr
|
@@ -1,16 +1,13 @@
|
|
1
|
-
require 'tilt'
|
2
|
-
|
3
1
|
module AngularRailsTemplates
|
4
2
|
class Engine < ::Rails::Engine
|
5
3
|
config.angular_templates = ActiveSupport::OrderedOptions.new
|
6
4
|
config.angular_templates.module_name = 'templates'
|
7
5
|
config.angular_templates.ignore_prefix = ['templates/']
|
8
|
-
config.angular_templates.inside_paths = []
|
6
|
+
config.angular_templates.inside_paths = ['app/assets']
|
9
7
|
config.angular_templates.markups = []
|
8
|
+
config.angular_templates.extension = 'html'
|
10
9
|
|
11
10
|
config.before_configuration do |app|
|
12
|
-
config.angular_templates.inside_paths = [Rails.root.join('app', 'assets')]
|
13
|
-
|
14
11
|
# try loading common markups
|
15
12
|
%w(erb haml liquid md radius slim str textile wiki).
|
16
13
|
each do |ext|
|
@@ -26,13 +23,9 @@ module AngularRailsTemplates
|
|
26
23
|
|
27
24
|
|
28
25
|
initializer 'angular-rails-templates', group: :all do |app|
|
29
|
-
if
|
30
|
-
require 'sprockets'
|
31
|
-
require 'sprockets/engines' # load sprockets for Rails 3
|
32
|
-
|
26
|
+
if defined?(Sprockets::Railtie)
|
33
27
|
config.assets.configure do |env|
|
34
|
-
|
35
|
-
env.register_mime_type 'text/ng-html', extensions: ['.html']
|
28
|
+
env.register_mime_type 'text/ng-html', extensions: [".#{app.config.angular_templates.extension}"]
|
36
29
|
env.register_transformer 'text/ng-html', 'application/javascript', AngularRailsTemplates::Processor
|
37
30
|
|
38
31
|
# These engines render markup as HTML
|
@@ -31,10 +31,16 @@ module AngularRailsTemplates
|
|
31
31
|
|
32
32
|
def template_name(name)
|
33
33
|
path = name.sub /^(#{config.ignore_prefix.join('|')})/, ''
|
34
|
-
"#{path}.
|
34
|
+
"#{path}.#{config.extension}"
|
35
35
|
end
|
36
36
|
|
37
37
|
def call(input)
|
38
|
+
file_path = Pathname.new(input[:filename]).relative_path_from(Rails.root).to_s
|
39
|
+
|
40
|
+
unless config.inside_paths.any? { |folder| file_path.match(folder.to_s) }
|
41
|
+
return input[:data]
|
42
|
+
end
|
43
|
+
|
38
44
|
locals = {}
|
39
45
|
locals[:angular_template_name] = template_name(input[:name])
|
40
46
|
locals[:angular_module] = config.module_name
|
@@ -42,11 +48,7 @@ module AngularRailsTemplates
|
|
42
48
|
|
43
49
|
locals[:html] = escape_javascript(input[:data].chomp)
|
44
50
|
|
45
|
-
|
46
|
-
AngularJsTemplateWrapper.render(nil, locals)
|
47
|
-
else
|
48
|
-
input[:data]
|
49
|
-
end
|
51
|
+
AngularJsTemplateWrapper.render(nil, locals)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
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.0.beta2
|
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-
|
13
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '3.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: tilt
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: minitest
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|