view_component 1.16.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE +27 -0
  3. data/.github/PULL_REQUEST_TEMPLATE +17 -0
  4. data/.github/workflows/ruby_on_rails.yml +31 -0
  5. data/.gitignore +53 -0
  6. data/.rubocop.yml +8 -0
  7. data/CHANGELOG.md +373 -0
  8. data/CODE_OF_CONDUCT.md +76 -0
  9. data/CONTRIBUTING.md +46 -0
  10. data/Gemfile +8 -0
  11. data/Gemfile.lock +202 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +460 -0
  14. data/Rakefile +12 -0
  15. data/app/controllers/rails/components_controller.rb +65 -0
  16. data/docs/case-studies/jellyswitch.md +76 -0
  17. data/lib/action_view/component.rb +4 -0
  18. data/lib/action_view/component/base.rb +13 -0
  19. data/lib/action_view/component/preview.rb +8 -0
  20. data/lib/action_view/component/railtie.rb +3 -0
  21. data/lib/action_view/component/test_case.rb +9 -0
  22. data/lib/action_view/component/test_helpers.rb +17 -0
  23. data/lib/rails/generators/component/USAGE +13 -0
  24. data/lib/rails/generators/component/component_generator.rb +44 -0
  25. data/lib/rails/generators/component/templates/component.rb.tt +5 -0
  26. data/lib/rails/generators/erb/component_generator.rb +21 -0
  27. data/lib/rails/generators/erb/templates/component.html.erb.tt +1 -0
  28. data/lib/rails/generators/haml/component_generator.rb +21 -0
  29. data/lib/rails/generators/haml/templates/component.html.haml.tt +1 -0
  30. data/lib/rails/generators/rspec/component_generator.rb +19 -0
  31. data/lib/rails/generators/rspec/templates/component_spec.rb.tt +13 -0
  32. data/lib/rails/generators/slim/component_generator.rb +21 -0
  33. data/lib/rails/generators/slim/templates/component.html.slim.tt +1 -0
  34. data/lib/rails/generators/test_unit/component_generator.rb +20 -0
  35. data/lib/rails/generators/test_unit/templates/component_test.rb.tt +10 -0
  36. data/lib/railties/lib/rails.rb +5 -0
  37. data/lib/railties/lib/rails/templates/rails/components/index.html.erb +8 -0
  38. data/lib/railties/lib/rails/templates/rails/components/preview.html.erb +1 -0
  39. data/lib/railties/lib/rails/templates/rails/components/previews.html.erb +6 -0
  40. data/lib/view_component.rb +30 -0
  41. data/lib/view_component/base.rb +279 -0
  42. data/lib/view_component/conversion.rb +9 -0
  43. data/lib/view_component/engine.rb +65 -0
  44. data/lib/view_component/preview.rb +78 -0
  45. data/lib/view_component/previewable.rb +25 -0
  46. data/lib/view_component/render_monkey_patch.rb +31 -0
  47. data/lib/view_component/rendering_monkey_patch.rb +13 -0
  48. data/lib/view_component/template_error.rb +9 -0
  49. data/lib/view_component/test_case.rb +9 -0
  50. data/lib/view_component/test_helpers.rb +39 -0
  51. data/lib/view_component/version.rb +11 -0
  52. data/script/bootstrap +6 -0
  53. data/script/console +8 -0
  54. data/script/install +6 -0
  55. data/script/release +6 -0
  56. data/script/test +6 -0
  57. data/view_component.gemspec +46 -0
  58. metadata +226 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b95c56d30fd1e36093504017055a6bbc887afaaf27f6d801d5ebc023c95663fa
4
+ data.tar.gz: 5815e617efc02b962202ffc7af13a4bdafc19aa80acd75e17e8c07aee10b16f4
5
+ SHA512:
6
+ metadata.gz: b5488a8639f3383c6abb9e01112e63122a6a19069f5438358fa615da00c155b88b88298ba7a3b591177e6d954cc263807d874e7594f58220df111b7dd3398750
7
+ data.tar.gz: 566d554ba24af618543d26f9a7269bd6a3c2c5a42de7e33306bdf14bc78304c2cf5c94ba2e850519ef5b835c03cfb1bc49bf188633c51f751ac02d1d2afb799a
@@ -0,0 +1,27 @@
1
+ <!-- **** Filing a Feature Request? Include these sections. **** -->
2
+
3
+ ### Feature request
4
+ <!-- Provide a summary of the behavior. -->
5
+
6
+ ### Motivation
7
+
8
+ <!-- What would you like to do with this feature? Can you provide
9
+ context or references to similar behavior in other libraries? -->
10
+
11
+ <!-- **** Filing a Bug Report? Include these sections: **** -->
12
+
13
+ ### Steps to reproduce
14
+ <!-- Provide a series of steps or, better yet, a link to a repo to demonstrate the bug you've identified. -->
15
+
16
+ ### Expected behavior
17
+ <!-- Tell us what should happen -->
18
+
19
+ ### Actual behavior
20
+ <!-- Tell us what happens instead -->
21
+
22
+ ### System configuration
23
+ **Rails version**:
24
+
25
+ **Ruby version**:
26
+
27
+ **Gem version**:
@@ -0,0 +1,17 @@
1
+ <!-- See https://github.com/github/view_component/blob/master/CONTRIBUTING.md#submitting-a-pull-request -->
2
+
3
+ ### Summary
4
+
5
+ <!-- Provide a general description of the code changes in your pull
6
+ request... were there any bugs you had fixed? If so, mention them. If
7
+ these bugs have open GitHub issues, be sure to tag them here as well,
8
+ to keep the conversation linked together. -->
9
+
10
+ ### Other Information
11
+
12
+ <!-- If there's anything else that's important and relevant to your pull
13
+ request, mention that information here. This could include
14
+ benchmarks, or other information.
15
+
16
+ If you are updating any of the CHANGELOG files or are asked to update the
17
+ CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file. -->
@@ -0,0 +1,31 @@
1
+ name: Ruby on Rails
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ rails_version: [5.0.0, 5.2.3, 6.0.0, master]
11
+ ruby_version: [2.5.x, 2.6.x, 2.7.x]
12
+ exclude:
13
+ - rails_version: master
14
+ ruby_version: 2.4.x
15
+ - rails_version: 6.0.0
16
+ ruby_version: 2.4.x
17
+ steps:
18
+ - uses: actions/checkout@master
19
+ - name: Setup Ruby
20
+ uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby_version }}
23
+ - name: Build and test with Rake
24
+ run: |
25
+ gem install bundler:1.17.3
26
+ bundle update
27
+ bundle install --jobs 4 --retry 3
28
+ bundle exec rake
29
+ bundle exec rubocop
30
+ env:
31
+ RAILS_VERSION: ${{ matrix.rails_version }}
data/.gitignore ADDED
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+ /test/log/*
13
+ /test/app/tmp/*
14
+ /test/tmp/*
15
+
16
+ # Used by dotenv library to load environment variables.
17
+ # .env
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ inherit_gem:
2
+ rubocop-github:
3
+ - config/default.yml
4
+ - config/rails.yml
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - "test/tmp/**/*"
data/CHANGELOG.md ADDED
@@ -0,0 +1,373 @@
1
+ # master
2
+
3
+ * ViewComponent generators do not not prompt for content requirement.
4
+
5
+ *Joel Hawksley*
6
+
7
+ # v1.16.0
8
+
9
+ * Add `refute_component_rendered` test helper.
10
+
11
+ *Joel Hawksley*
12
+
13
+ * Check for Rails before invocation.
14
+
15
+ *Dave Paola*
16
+
17
+ * Allow components to be rendered without a template file (aka inline component).
18
+
19
+ *Rainer Borene*
20
+
21
+ # v1.15.0
22
+
23
+ * Re-introduce ActionView::Component::TestHelpers.
24
+
25
+ *Joel Hawksley*
26
+
27
+ * Bypass monkey patch on Rails 6.1 builds.
28
+
29
+ *Joel Hawksley*
30
+
31
+ * Make `ActionView::Helpers::TagHelper` available in Previews.
32
+
33
+ ```ruby
34
+ def with_html_content
35
+ render(MyComponent.new) do
36
+ tag.div do
37
+ content_tag(:span, "Hello")
38
+ end
39
+ end
40
+ end
41
+ ```
42
+
43
+ *Sean Doyle*
44
+
45
+ # v1.14.1
46
+
47
+ * Fix bug where generator created invalid test code.
48
+
49
+ *Joel Hawksley*
50
+
51
+ # v1.14.0
52
+
53
+ * Rename ActionView::Component::Base to ViewComponent::Base
54
+
55
+ *Joel Hawksley*
56
+
57
+ # v1.13.0
58
+
59
+ * Allow components to be rendered inside controllers.
60
+
61
+ *Joel Hawksley*
62
+
63
+ * Improve backtraces from exceptions raised in templates.
64
+
65
+ *Blake Williams*
66
+
67
+ # v1.12.0
68
+
69
+ * Revert: Remove initializer requirement for Ruby 2.7+
70
+
71
+ *Joel Hawksley*
72
+
73
+ * Restructure Railtie into Engine
74
+
75
+ *Sean Doyle*
76
+
77
+ * Allow components to override before_render_check
78
+
79
+ *Joel Hawksley*
80
+
81
+ # v1.11.1
82
+
83
+ * Relax Capybara requirement.
84
+
85
+ *Joel Hawksley*
86
+
87
+ # v1.11.0
88
+
89
+ * Add support for Capybara matchers.
90
+
91
+ *Joel Hawksley*
92
+
93
+ * Add erb, haml, & slim template generators
94
+
95
+ *Asger Behncke Jacobsen*
96
+
97
+ # v1.10.0
98
+
99
+ * Deprecate all `render` syntaxes except for `render(MyComponent.new(foo: :bar))`
100
+
101
+ *Joel Hawksley*
102
+
103
+ # v1.9.0
104
+
105
+ * Remove initializer requirement for Ruby 2.7+
106
+
107
+ *Dylan Clark*
108
+
109
+ # v1.8.1
110
+
111
+ * Run validation checks before calling `#render?`.
112
+
113
+ *Ash Wilson*
114
+
115
+ # v1.8.0
116
+
117
+ * Remove the unneeded ComponentExamplesController and simplify preview rendering.
118
+
119
+ *Jon Palmer*
120
+
121
+ * Add `#render?` hook to easily allow components to be no-ops.
122
+
123
+ *Kyle Fox*
124
+
125
+ * Don't assume ApplicationController exists.
126
+
127
+ *Jon Palmer*
128
+
129
+ * Allow some additional checks to overrided render?
130
+
131
+ *Sergey Malykh*
132
+
133
+ * Fix generator placing namespaced components in the root directory.
134
+
135
+ *Asger Behncke Jacobsen*
136
+
137
+ * Fix cache test.
138
+
139
+ *Sergey Malykh*
140
+
141
+ # v1.7.0
142
+
143
+ * Simplify validation of templates and compilation.
144
+
145
+ *Jon Palmer*
146
+
147
+ * Add support for multiple content areas.
148
+
149
+ *Jon Palmer*
150
+
151
+ # v1.6.2
152
+
153
+ * Fix Uninitialized Constant error.
154
+
155
+ *Jon Palmer*
156
+
157
+ * Add basic github issue and PR templates.
158
+
159
+ *Dylan Clark*
160
+
161
+ * Update readme phrasing around previews.
162
+
163
+ *Justin Coyne*
164
+
165
+ # v1.6.1
166
+
167
+ * Allow Previews to have no layout.
168
+
169
+ *Jon Palmer*
170
+
171
+ * Bump rack from 2.0.7 to 2.0.8.
172
+
173
+ *Dependabot*
174
+
175
+ * Compile components on application boot when eager loading is enabled.
176
+
177
+ *Joel Hawksley*
178
+
179
+ * Previews support content blocks.
180
+
181
+ *Cesario Uy*
182
+
183
+ * Follow Rails conventions. (refactor)
184
+
185
+ *Rainer Borene*
186
+
187
+ * Fix edge case issue with extracting variants from less conventional source_locations.
188
+
189
+ *Ryan Workman*
190
+
191
+ # v1.6.0
192
+
193
+ * Avoid dropping elements in the render_inline test helper.
194
+
195
+ *@dark-panda*
196
+
197
+ * Add test for helpers.asset_url.
198
+
199
+ *Christopher Coleman*
200
+
201
+ * Add rudimentary compatibility with better_html.
202
+
203
+ *Joel Hawksley*
204
+
205
+ * Template-less variants fall back to default template.
206
+
207
+ *Asger Behncke Jacobsen*, *Cesario Uy*
208
+
209
+ * Generated tests use new naming convention.
210
+
211
+ *Simon Træls Ravn*
212
+
213
+ * Eliminate sqlite dependency.
214
+
215
+ *Simon Dawson*
216
+
217
+ * Add support for rendering components via #to_component_class
218
+
219
+ *Vinicius Stock*
220
+
221
+ # v1.5.3
222
+
223
+ * Add support for RSpec to generators.
224
+
225
+ *Dylan Clark, Ryan Workman*
226
+
227
+ * Require controllers as part of setting autoload paths.
228
+
229
+ *Joel Hawksley*
230
+
231
+ # v1.5.2
232
+
233
+ * Disable eager loading initializer.
234
+
235
+ *Kasper Meyer*
236
+
237
+ # v1.5.1
238
+
239
+ * Update railties class to work with Rails 6.
240
+
241
+ *Juan Manuel Ramallo*
242
+
243
+ # v1.5.0
244
+
245
+ Note: `actionview-component` is now loaded by requiring `actionview/component`, not `actionview/component/base`.
246
+
247
+ * Fix issue with generating component method signatures.
248
+
249
+ *Ryan Workman, Dylan Clark*
250
+
251
+ * Create component generator.
252
+
253
+ *Vinicius Stock*
254
+
255
+ * Add helpers proxy.
256
+
257
+ *Kasper Meyer*
258
+
259
+ * Introduce ActionView::Component::Previews.
260
+
261
+ *Juan Manuel Ramallo*
262
+
263
+ # v1.4.0
264
+
265
+ * Fix bug where components broke in application paths with periods.
266
+
267
+ *Anton, Joel Hawksley*
268
+
269
+ * Add support for `cache_if` in component templates.
270
+
271
+ *Aaron Patterson, Joel Hawksley*
272
+
273
+ * Add support for variants.
274
+
275
+ *Juan Manuel Ramallo*
276
+
277
+ * Fix bug in virtual path lookup.
278
+
279
+ *Juan Manuel Ramallo*
280
+
281
+ * Preselect the rendered component in render_inline.
282
+
283
+ *Elia Schito*
284
+
285
+ # v1.3.6
286
+
287
+ * Allow template file names without format.
288
+
289
+ *Joel Hawksley*
290
+
291
+ * Add support for translations.
292
+
293
+ *Juan Manuel Ramallo*
294
+
295
+ # v1.3.5
296
+
297
+ * Re-expose `controller` method.
298
+
299
+ *Michael Emhofer, Joel Hawksley*
300
+
301
+ * Gem version numbers are now accessible through `ActionView::Component::VERSION`
302
+
303
+ *Richard Macklin*
304
+
305
+ * Fix typo in README
306
+
307
+ *ars moriendi*
308
+
309
+ # v1.3.4
310
+
311
+ * Template errors surface correct file and line number.
312
+
313
+ *Justin Coyne*
314
+
315
+ * Allow access to `request` inside components.
316
+
317
+ *Joel Hawksley*
318
+
319
+ # v1.3.3
320
+
321
+ * Do not raise error when sidecar files that are not templates exist.
322
+
323
+ *Joel Hawksley*
324
+
325
+ # v1.3.2
326
+
327
+ * Support rendering views from inside component templates.
328
+
329
+ *Patrick Sinclair*
330
+
331
+ # v1.3.1
332
+
333
+ * Fix bug where rendering nested content caused an error.
334
+
335
+ *Joel Hawksley, Aaron Patterson*
336
+
337
+ # v1.3.0
338
+
339
+ * Components are rendered with enough controller context to support rendering of partials and forms.
340
+
341
+ *Patrick Sinclair, Joel Hawksley, Aaron Patterson*
342
+
343
+ # v1.2.1
344
+
345
+ * `actionview-component` is now tested against Ruby 2.3/2.4 and Rails 5.0.0.
346
+
347
+ # v1.2.0
348
+
349
+ * The `render_component` test helper has been renamed to `render_inline`. `render_component` has been deprecated and will be removed in v2.0.0.
350
+
351
+ *Joel Hawksley*
352
+
353
+ * Components are now rendered with `render MyComponent, foo: :bar` syntax. The existing `render MyComponent.new(foo: :bar)` syntax has been deprecated and will be removed in v2.0.0.
354
+
355
+ *Joel Hawksley*
356
+
357
+ # v1.1.0
358
+
359
+ * Components now inherit from ActionView::Component::Base
360
+
361
+ *Joel Hawksley*
362
+
363
+ # v1.0.1
364
+
365
+ * Always recompile component templates outside production.
366
+
367
+ *Joel Hawksley, John Hawthorn*
368
+
369
+ # v1.0.0
370
+
371
+ This release extracts the `ActionView::Component` library from the GitHub application.
372
+
373
+ It will be published on RubyGems under the existing `actionview-component` gem name, as @chancancode has passed us ownership of the gem.