actionview_precompiler 0.2.0 → 0.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c8e4204b2ff2f95e85606497693d399460c4c31a8f946706a503be04b03d5f8
|
4
|
+
data.tar.gz: 8aa824e50eaa357b9f0084756c9399f928b8ead2e2a04fe24ab2bbbe4b611400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbfa31585cea6678aec9b4e0b7fa592f439e4d2f3aa9428faa7583a9c32a701a880343e66843c8ef7afa9d146b8a2542a078c2de622211750fe8c516ddbe0bed
|
7
|
+
data.tar.gz: b1655ba9a3639df1ac3d26b15297d3909e1fbfb6f323152f3a8bf3aca956d229d7d848bbc291a438c2aa5069a0d889f4f1c4b14280868ab33011160611847219
|
@@ -78,8 +78,14 @@ module ActionviewPrecompiler
|
|
78
78
|
@templates.each do |template|
|
79
79
|
parser = TemplateParser.new(template.fullpath)
|
80
80
|
parser.render_calls.each do |render_call|
|
81
|
-
|
82
|
-
|
81
|
+
virtual_path = render_call.virtual_path
|
82
|
+
unless virtual_path.include?("/")
|
83
|
+
# Not necessarily true, since the perfix is based on the current
|
84
|
+
# controller, but is a safe bet most of the time.
|
85
|
+
virtual_path = "#{template.prefix}/#{virtual_path}"
|
86
|
+
end
|
87
|
+
@locals_sets[virtual_path] ||= []
|
88
|
+
@locals_sets[virtual_path] << render_call.locals_keys.map(&:to_s).sort
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
@@ -2,7 +2,7 @@ module ActionviewPrecompiler
|
|
2
2
|
RenderCall = Struct.new(:render_type, :template, :locals, :locals_keys) do
|
3
3
|
def virtual_path
|
4
4
|
if render_type == :partial
|
5
|
-
@virtual_path ||= template.gsub(%r{
|
5
|
+
@virtual_path ||= template.gsub(%r{(/|^)([^/]*)\z}, '\1_\2')
|
6
6
|
else
|
7
7
|
template
|
8
8
|
end
|
@@ -61,7 +61,7 @@ module ActionviewPrecompiler
|
|
61
61
|
|
62
62
|
RENDER_TYPE_KEYS = [:partial, :template, :layout]
|
63
63
|
IGNORED_KEYS = [:formats]
|
64
|
-
ALL_KNOWN_KEYS = [*RENDER_TYPE_KEYS, *IGNORED_KEYS, :locals]
|
64
|
+
ALL_KNOWN_KEYS = [*RENDER_TYPE_KEYS, *IGNORED_KEYS, :locals, :object, :collection, :as]
|
65
65
|
|
66
66
|
def parse_render_from_options(options_hash)
|
67
67
|
keys = options_hash.keys
|
@@ -93,6 +93,25 @@ module ActionviewPrecompiler
|
|
93
93
|
locals_keys = []
|
94
94
|
end
|
95
95
|
|
96
|
+
if options_hash.key?(:object) || options_hash.key?(:collection)
|
97
|
+
return nil if options_hash.key?(:object) && options_hash.key?(:collection)
|
98
|
+
return nil unless options_hash.key?(:partial)
|
99
|
+
|
100
|
+
as = if options_hash.key?(:as)
|
101
|
+
parse_str(options_hash[:as]) || parse_sym(options_hash[:as])
|
102
|
+
elsif File.basename(template) =~ /\A_?(.*?)(?:\.\w+)*\z/
|
103
|
+
$1
|
104
|
+
end
|
105
|
+
|
106
|
+
return nil unless as
|
107
|
+
|
108
|
+
locals_keys << as.to_sym
|
109
|
+
if options_hash.key?(:collection)
|
110
|
+
locals_keys << :"#{as}_counter"
|
111
|
+
locals_keys << :"#{as}_iteration"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
96
115
|
RenderCall.new(render_type, template, locals, locals_keys)
|
97
116
|
end
|
98
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview_precompiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|