view_component_helper 0.4.3 → 0.4.4
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: 9b14cab38b32ee81aa0cc440c6ace3233c681bf567d3af063b260cc10d7ffd68
|
4
|
+
data.tar.gz: 33eec3e87d67cdf41fe9c7741ebedd3583f0dd0b6cd4fe22c8f4d17c7d31da0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6110fdd56c17863aa506f5268037482f6727c600acc901e4deb6e20a219c98bafda4eb6a0ce9a5d3b4ad69622896397cc088614204c7ae339e8ee00039f44433
|
7
|
+
data.tar.gz: 5d86f6a095be702ede49c7c39606748103527f3881a0e16ea984a494103dbbcd594e4b8f11170b6a085223cbd97cf6c430bb342453bd75ad4e3e56309a96c57c
|
@@ -1,18 +1,31 @@
|
|
1
|
+
#
|
2
|
+
#
|
3
|
+
#
|
1
4
|
module ViewComponentHelper
|
2
|
-
def render_view_component(path, *args, **kwargs, &)
|
3
|
-
render
|
5
|
+
def render_view_component(path, *args, **kwargs, &block)
|
6
|
+
render path.classify.constantize.new(*args, **kwargs, &block)
|
4
7
|
end
|
5
8
|
|
6
9
|
alias render_vc render_view_component
|
7
10
|
alias vc render_view_component
|
8
11
|
|
9
|
-
|
12
|
+
def self.load_components
|
13
|
+
Dir[Rails.root.join('app/components/**/*.rb')].each do |file|
|
14
|
+
require file
|
10
15
|
|
11
|
-
|
12
|
-
|
16
|
+
component_path = file.gsub("#{Rails.root.join('app/components')}/", '').gsub('.rb', '')
|
17
|
+
component_class_name = component_path.camelize # don't use classify
|
18
|
+
method_name = component_path.gsub('/', '_')
|
19
|
+
|
20
|
+
next unless Object.const_defined?(component_class_name) && component_class_name.constantize < ViewComponent::Base
|
21
|
+
|
22
|
+
define_method(method_name) do |*args, **kwargs, &block|
|
23
|
+
render component_class_name.constantize.new(*args, **kwargs, &block)
|
24
|
+
end
|
25
|
+
end
|
13
26
|
end
|
14
27
|
end
|
15
28
|
|
16
29
|
ActiveSupport.on_load :action_view do
|
17
30
|
include ViewComponentHelper
|
18
|
-
end
|
31
|
+
end if defined?(ActiveSupport)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yamitake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'The ''view_component_helper'' gem streamlines View helper method invocation
|
14
14
|
for view_component. Simplify integration and boost productivity. '
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- README.md
|
28
28
|
- Rakefile
|
29
29
|
- lib/view_component_helper.rb
|
30
|
+
- lib/view_component_helper/railtie.rb
|
30
31
|
- lib/view_component_helper/version.rb
|
31
32
|
- lib/view_component_helper/view_helper.rb
|
32
33
|
- sig/view_component_helper.rbs
|