view_component_helper 0.9.0 → 0.9.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: 10a71a7f76a97313e83592765258db61e924f0fbbbce53e3809794c9f91cacaa
4
- data.tar.gz: 5711f1eb3b405d2936c3a1365a12096c25e518b24df60ba7d944a85be4ef313f
3
+ metadata.gz: 5966bd782f29a9d3e10a9bd583c6d79d7239f2f767de4cd3e4e5a13b302e0e81
4
+ data.tar.gz: 7c6fc694458ae9dd2d583b6d7df13c482399b81f3c4c618c979bc6d7288baf84
5
5
  SHA512:
6
- metadata.gz: d360c889b42c61214786d9c8f6f9a7f2e17e610aef8750c64bcd22fa46fa7b59f3e02aa4ba379c96074b36df4de066515c44941f4bf134642f656ff7034b3fc6
7
- data.tar.gz: 54cc3a3298c3e4e4910f9b4c94d72fd15cfaa062b891a8c902ce62cfd296082dddc600f70916b04a77b809628504b35ead357510ddc70f3d19e96757419c854b
6
+ metadata.gz: 70c4004614931d4caa0f88de8f07fd9dd312c9e456450b4c8094225aeb760c3d876be8339cc6daa22c92e8dde428f038e37876a24ccab61fc0be2f2c51033eff
7
+ data.tar.gz: d75ee370dfc30a75114c4012f55c6ff0b6d89f370678957ca04b0d1a07e570db6d6a88e223d21a482df022f525883c876b8a8f3f3e9709f36c8f0f02f87cedf3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- view_component_helper (0.9.0)
4
+ view_component_helper (0.9.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # ViewComponentHelper
2
+ [![Gem Version](https://badge.fury.io/rb/view_component_helper.svg)](https://badge.fury.io/rb/view_component_helper)
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/view_component_helper`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+ `ViewComponentHelper` is a simple gem designed to enhance the functionality provided by [ViewComponent](https://github.com/ViewComponent/view_component). It offers shortcuts to access generated ViewComponents, making your Rails development experience smoother and more efficient.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
6
 
7
7
  ## Installation
8
8
 
@@ -30,15 +30,40 @@ or
30
30
  <%= vc("messageComponent", name: "World") %>
31
31
  ```
32
32
 
33
- Make sure to incorporate ViewComponent as described in the reference link to enhance your application's functionality.
33
+ ## Usage
34
+ For more information on ViewComponents, please refer to the [official documentation](https://viewcomponent.org/).
35
+
36
+ `ViewComponentHelper` allows for easier referencing of `ViewComponent` classes located under the `app/components` directory by providing you with intuitive shortcut methods.
37
+
38
+ ### How it works
39
+ For every `ViewComponent` you define within the `app/components` directory, `ViewComponentHelper` automatically provides a shortcut method to render it.
40
+
41
+ ### Examples
34
42
 
43
+ 1. For a component located at `app/components/title_component.rb`:
35
44
 
45
+ You can utilize the following shortcut:
46
+ ```ruby
47
+ title_component(title: "test title")
48
+ ```
49
+
50
+ 2. For a component located at `app/components/button.rb`:
36
51
 
37
- ## Development
52
+ ```erb
53
+ <%= button %>
54
+ ```
38
55
 
39
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
+ 3. For a component located at `app/components/dialog/component.rb`
40
57
 
41
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
+ ```erb
59
+ <%= dialog_component do |c| %>
60
+ <% c.with_title { "dialog title" } %>
61
+ <% c.with_body do %>
62
+ <p>this is dialog body</p>
63
+ <% end %>
64
+ <div>content</div>
65
+ <% end %>
66
+ ```
42
67
 
43
68
  ## Contributing
44
69
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViewComponentHelper
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
@@ -15,7 +15,9 @@ module ViewComponentHelper
15
15
  if collection
16
16
  render component_klass.with_collection(collection, *args, **kwargs, &block)
17
17
  else
18
- render component_klass.new(*args, **kwargs, &block)
18
+ component_instance = component_klass.new(*args, **kwargs)
19
+ component_instance.instance_exec(&block) if block_given?
20
+ render(component_instance)
19
21
  end
20
22
  end
21
23
 
@@ -43,7 +45,8 @@ module ViewComponentHelper
43
45
  if collection
44
46
  render component_klass.with_collection(collection, *args, **kwargs, &block)
45
47
  else
46
- render component_klass.new(*args, **kwargs, &block)
48
+ component_instance = component_klass.new(*args, **kwargs, &block)
49
+ render component_instance
47
50
  end
48
51
  end
49
52
  end
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yamitake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-23 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Simplify integration and boost productivity. '
14
14
  email: