actionview-component 1.7.0 → 1.8.0
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 +4 -4
- data/.github/ISSUE_TEMPLATE +3 -8
- data/.github/PULL_REQUEST_TEMPLATE +2 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +4 -13
- data/Gemfile.lock +1 -1
- data/README.md +92 -3
- data/lib/action_view/component/base.rb +14 -1
- data/lib/action_view/component/preview.rb +7 -15
- data/lib/action_view/component/railtie.rb +0 -1
- data/lib/action_view/component/test_helpers.rb +1 -1
- data/lib/action_view/component/version.rb +1 -1
- data/lib/rails/generators/component/component_generator.rb +2 -2
- data/lib/rails/generators/rspec/component_generator.rb +1 -1
- data/lib/rails/generators/test_unit/component_generator.rb +1 -1
- data/lib/railties/lib/rails.rb +0 -1
- data/lib/railties/lib/rails/components_controller.rb +5 -1
- data/lib/railties/lib/rails/templates/rails/components/preview.html.erb +1 -1
- metadata +2 -4
- data/lib/railties/lib/rails/component_examples_controller.rb +0 -9
- data/lib/railties/lib/rails/templates/rails/examples/show.html.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab99ff30cf5a1d5fad5d3f670936b813d8923b9e4e5a3db566c0c08fa8cb7550
|
4
|
+
data.tar.gz: 7432ee39d40af863647a1cdf220b7775592bfef12c84bbc8a6175d741b88c2ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a8dc19f3caa79baf1c2fc754ee0b715885b83eaae13a7a3b6f2f25fb574dd6a0b109cd61328444abaf93ef55ded12413d59a5343fc707c544baba766c14ae7
|
7
|
+
data.tar.gz: a73449076c9d073052c97ad8cc0d58a88d40f8973a576221a41d7b9e7ed15aeecd0d3704694e4f78bf918fbe6f4d875df0f389f71381b81ad0fed7f8fb4720d3
|
data/.github/ISSUE_TEMPLATE
CHANGED
@@ -6,17 +6,12 @@
|
|
6
6
|
### Motivation
|
7
7
|
|
8
8
|
<!-- What would you like to do with this feature? Can you provide
|
9
|
-
context or references to similar behavior in other libraries
|
9
|
+
context or references to similar behavior in other libraries? -->
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<!-- **** Filing a Bug Report? Include these sections. **** -->
|
11
|
+
<!-- **** Filing a Bug Report? Include these sections: **** -->
|
16
12
|
|
17
13
|
### Steps to reproduce
|
18
|
-
<!-- Provide
|
19
|
-
demonstrate the bug you've identified. -->
|
14
|
+
<!-- Provide a series of steps or, better yet, a link to a repo to demonstrate the bug you've identified. -->
|
20
15
|
|
21
16
|
### Expected behavior
|
22
17
|
<!-- Tell us what should happen -->
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<!-- https://github.com/github/actionview-component/blob/master/CONTRIBUTING.md#submitting-a-pull-request -->
|
1
|
+
<!-- See https://github.com/github/actionview-component/blob/master/CONTRIBUTING.md#submitting-a-pull-request -->
|
2
2
|
|
3
3
|
### Summary
|
4
4
|
|
@@ -14,6 +14,4 @@ request, mention that information here. This could include
|
|
14
14
|
benchmarks, or other information.
|
15
15
|
|
16
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.
|
18
|
-
|
19
|
-
Thanks for contributing to actionview-component! -->
|
17
|
+
CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file. -->
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# v1.8.0
|
2
|
+
|
3
|
+
* Remove the unneeded ComponentExamplesController and simplify preview rendering.
|
4
|
+
|
5
|
+
*Jon Palmer*
|
6
|
+
|
7
|
+
* Add `#render?` hook to easily allow components to be no-ops.
|
8
|
+
|
9
|
+
*Kyle Fox*
|
10
|
+
|
11
|
+
* Don't assume ApplicationController exists.
|
12
|
+
|
13
|
+
*Jon Palmer*
|
14
|
+
|
15
|
+
* Allow some additional checks to overrided render?
|
16
|
+
|
17
|
+
*Sergey Malykh*
|
18
|
+
|
19
|
+
* Fix generator placing namespaced components in the root directory.
|
20
|
+
|
21
|
+
*Asger Behncke Jacobsen*
|
22
|
+
|
23
|
+
* Fix cache test.
|
24
|
+
|
25
|
+
*Sergey Malykh*
|
26
|
+
|
1
27
|
# v1.7.0
|
2
28
|
|
3
29
|
* Simplify validation of templates and compilation.
|
data/CONTRIBUTING.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Contributing
|
2
2
|
|
3
3
|
[fork]: https://github.com/github/actionview-component/fork
|
4
4
|
[pr]: https://github.com/github/actionview-component/compare
|
@@ -15,9 +15,11 @@ Please note that this project is released with a [Contributor Code of Conduct][c
|
|
15
15
|
|
16
16
|
0. [Fork][fork] and clone the repository
|
17
17
|
0. Configure and install the dependencies: `bundle`
|
18
|
-
0. Make sure the tests pass on your machine: `rake`
|
18
|
+
0. Make sure the tests pass on your machine: `bundle exec rake`
|
19
19
|
0. Create a new branch: `git checkout -b my-branch-name`
|
20
20
|
0. Make your change, add tests, and make sure the tests still pass
|
21
|
+
0. Add an entry to the top of `CHANGELOG.md` for your changes
|
22
|
+
0. If it's your first time contributing, add yourself to the contributors at the bottom of `README.md`
|
21
23
|
0. Push to your fork and [submit a pull request][pr]
|
22
24
|
0. Pat your self on the back and wait for your pull request to be reviewed and merged.
|
23
25
|
|
@@ -36,20 +38,9 @@ If you are the current maintainer of this gem:
|
|
36
38
|
1. Add version heading/entries to `CHANGELOG.md`.
|
37
39
|
1. Make sure your local dependencies are up to date: `bundle`
|
38
40
|
1. Ensure that tests are green: `bundle exec rake`
|
39
|
-
1. Build a test gem `GEM_VERSION=$(git describe --tags 2>/dev/null | sed 's/-/./g' | sed 's/v//') gem build actionview-component.gemspec`
|
40
|
-
1. Test the test gem:
|
41
|
-
1. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
|
42
|
-
1. Install the new gem locally
|
43
|
-
1. Test behavior locally, branch deploy, whatever needs to happen
|
44
41
|
1. Make a PR to github/actionview-component.
|
45
42
|
1. Build a local gem: `gem build actionview-component.gemspec`
|
46
43
|
1. Merge github/actionview-component PR
|
47
44
|
1. Tag and push: `git tag vx.xx.xx; git push --tags`
|
48
45
|
1. Create a GitHub release with the pushed tag (https://github.com/github/actionview-component/releases/new) and populate it with a list of the commits from `git log --pretty=format:"- %s" --reverse refs/tags/[OLD TAG]...refs/tags/[NEW TAG]`
|
49
46
|
1. Push to rubygems.org -- `gem push actionview-component-VERSION.gem`
|
50
|
-
|
51
|
-
## Resources
|
52
|
-
|
53
|
-
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
54
|
-
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
|
55
|
-
- [GitHub Help](https://help.github.com)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -201,7 +201,6 @@ An error will be raised:
|
|
201
201
|
|
202
202
|
#### Content Areas
|
203
203
|
|
204
|
-
|
205
204
|
A component can declare additional content areas to be rendered in the component. For example:
|
206
205
|
|
207
206
|
`app/components/modal_component.rb`:
|
@@ -304,7 +303,7 @@ end
|
|
304
303
|
```erb
|
305
304
|
<%= render(ModalComponent) do |component| %>
|
306
305
|
<% component.with(:header) do %>
|
307
|
-
<span class="help_icon">Hello</span>
|
306
|
+
<span class="help_icon">Hello</span>
|
308
307
|
<% end %>
|
309
308
|
<% component.with(:body) do %>
|
310
309
|
<p>Have a great day.</p>
|
@@ -350,7 +349,7 @@ end
|
|
350
349
|
```erb
|
351
350
|
<%= render(ModalComponent) do |component| %>
|
352
351
|
<% component.with(:header) do %>
|
353
|
-
<span class="help_icon">Hello</span>
|
352
|
+
<span class="help_icon">Hello</span>
|
354
353
|
<% end %>
|
355
354
|
<% component.with(:body) do %>
|
356
355
|
<p>Have a great day.</p>
|
@@ -367,6 +366,57 @@ end
|
|
367
366
|
<% end %>
|
368
367
|
```
|
369
368
|
|
369
|
+
### Conditional Rendering
|
370
|
+
|
371
|
+
Components can implement a `#render?` method which indicates if they should be rendered, or not at all.
|
372
|
+
|
373
|
+
For example, you might have a component that displays a "Please confirm your email address" banner to users who haven't confirmed their email address. The logic for rendering the banner would need to go in either the component template:
|
374
|
+
|
375
|
+
```
|
376
|
+
<!-- app/components/confirm_email_component.html.erb -->
|
377
|
+
<% if user.requires_confirmation? %>
|
378
|
+
<div class="alert">
|
379
|
+
Please confirm your email address.
|
380
|
+
</div>
|
381
|
+
<% end %>
|
382
|
+
```
|
383
|
+
|
384
|
+
or the view that renders the component:
|
385
|
+
|
386
|
+
```erb
|
387
|
+
<!-- app/views/_banners.html.erb -->
|
388
|
+
<% if current_user.requires_confirmation? %>
|
389
|
+
<%= render(ConfirmEmailComponent, user: current_user) %>
|
390
|
+
<% end %>
|
391
|
+
```
|
392
|
+
|
393
|
+
The `#render?` hook allows you to move this logic into the Ruby class, leaving your views more readable and declarative in style:
|
394
|
+
|
395
|
+
```ruby
|
396
|
+
# app/components/confirm_email_component.rb
|
397
|
+
class ConfirmEmailComponent < ApplicationComponent
|
398
|
+
def initialize(user:)
|
399
|
+
@user = user
|
400
|
+
end
|
401
|
+
|
402
|
+
def render?
|
403
|
+
@user.requires_confirmation?
|
404
|
+
end
|
405
|
+
end
|
406
|
+
```
|
407
|
+
|
408
|
+
```
|
409
|
+
<!-- app/components/confirm_email_component.html.erb -->
|
410
|
+
<div class="banner">
|
411
|
+
Please confirm your email address.
|
412
|
+
</div>
|
413
|
+
```
|
414
|
+
|
415
|
+
```erb
|
416
|
+
<!-- app/views/_banners.html.erb -->
|
417
|
+
<%= render(ConfirmEmailComponent, user: current_user) %>
|
418
|
+
```
|
419
|
+
|
370
420
|
### Testing
|
371
421
|
|
372
422
|
Components are unit tested directly. The `render_inline` test helper wraps the result in `Nokogiri.HTML`, allowing us to test the component above as:
|
@@ -444,6 +494,16 @@ For example, if you want to use `lib/component_previews`, set the following in `
|
|
444
494
|
config.action_view_component.preview_path = "#{Rails.root}/lib/component_previews"
|
445
495
|
```
|
446
496
|
|
497
|
+
#### Configuring TestController
|
498
|
+
|
499
|
+
By default components tests and previews expect your Rails project to contain an `ApplicationController` class from which Controller classes inherit.
|
500
|
+
This can be configured using the `test_controller` option.
|
501
|
+
For example, if your controllers inherit from `BaseController`, set the following in `config/application.rb`:
|
502
|
+
|
503
|
+
```ruby
|
504
|
+
config.action_view_component.test_controller = "BaseController"
|
505
|
+
```
|
506
|
+
|
447
507
|
### Setting up RSpec
|
448
508
|
|
449
509
|
If you're using RSpec, you can configure component specs to have access to test helpers. Add the following to
|
@@ -499,6 +559,35 @@ Inline templates have been removed (for now) due to concerns raised by [@soutaro
|
|
499
559
|
|
500
560
|
Bug reports and pull requests are welcome on GitHub at https://github.com/github/actionview-component. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. We recommend reading the [contributing guide](./CONTRIBUTING.md) as well.
|
501
561
|
|
562
|
+
## Contributors
|
563
|
+
|
564
|
+
`actionview-component` is built by:
|
565
|
+
|
566
|
+
|<img src="https://avatars.githubusercontent.com/joelhawksley?s=256" alt="joelhawksley" width="128" />|<img src="https://avatars.githubusercontent.com/tenderlove?s=256" alt="tenderlove" width="128" />|<img src="https://avatars.githubusercontent.com/jonspalmer?s=256" alt="jonspalmer" width="128" />|<img src="https://avatars.githubusercontent.com/juanmanuelramallo?s=256" alt="juanmanuelramallo" width="128" />|<img src="https://avatars.githubusercontent.com/vinistock?s=256" alt="vinistock" width="128" />|
|
567
|
+
|:---:|:---:|:---:|:---:|:---:|
|
568
|
+
|@joelhawksley|@tenderlove|@jonspalmer|@juanmanuelramallo|@vinistock|
|
569
|
+
|Denver|Seattle|Boston||Toronto|
|
570
|
+
|
571
|
+
|<img src="https://avatars.githubusercontent.com/metade?s=256" alt="metade" width="128" />|<img src="https://avatars.githubusercontent.com/asgerb?s=256" alt="asgerb" width="128" />|<img src="https://avatars.githubusercontent.com/xronos-i-am?s=256" alt="xronos-i-am" width="128" />|<img src="https://avatars.githubusercontent.com/dylnclrk?s=256" alt="dylnclrk" width="128" />|<img src="https://avatars.githubusercontent.com/kaspermeyer?s=256" alt="kaspermeyer" width="128" />|
|
572
|
+
|:---:|:---:|:---:|:---:|:---:|
|
573
|
+
|@metade|@asgerb|@xronos-i-am|@dylnclrk|@kaspermeyer|
|
574
|
+
|London|Copenhagen|Russia, Kirov|Berkeley, CA|Denmark|
|
575
|
+
|
576
|
+
|<img src="https://avatars.githubusercontent.com/rdavid1099?s=256" alt="rdavid1099" width="128" />|<img src="https://avatars.githubusercontent.com/kylefox?s=256" alt="kylefox" width="128" />|<img src="https://avatars.githubusercontent.com/traels?s=256" alt="traels" width="128" />|<img src="https://avatars.githubusercontent.com/rainerborene?s=256" alt="rainerborene" width="128" />|<img src="https://avatars.githubusercontent.com/jcoyne?s=256" alt="jcoyne" width="128" />|
|
577
|
+
|:---:|:---:|:---:|:---:|:---:|
|
578
|
+
|@rdavid1099|@kylefox|@traels|@rainerborene|@jcoyne|
|
579
|
+
|Los Angeles|Edmonton|Odense, Denmark|Brazil|Minneapolis|
|
580
|
+
|
581
|
+
|<img src="https://avatars.githubusercontent.com/elia?s=256" alt="elia" width="128" />|<img src="https://avatars.githubusercontent.com/cesariouy?s=256" alt="cesariouy" width="128" />|<img src="https://avatars.githubusercontent.com/spdawson?s=256" alt="spdawson" width="128" />|<img src="https://avatars.githubusercontent.com/rmacklin?s=256" alt="rmacklin" width="128" />|<img src="https://avatars.githubusercontent.com/michaelem?s=256" alt="michaelem" width="128" />|
|
582
|
+
|:---:|:---:|:---:|:---:|:---:|
|
583
|
+
|@elia|@cesariouy|@spdawson|@rmacklin|@michaelem|
|
584
|
+
|Milan||United Kingdom||Berlin|
|
585
|
+
|
586
|
+
|<img src="https://avatars.githubusercontent.com/mellowfish?s=256" alt="mellowfish" width="128" />|<img src="https://avatars.githubusercontent.com/horacio?s=256" alt="horacio" width="128" />|<img src="https://avatars.githubusercontent.com/dukex?s=256" alt="dukex" width="128" />|<img src="https://avatars.githubusercontent.com/dark-panda?s=256" alt="dark-panda" width="128" />|
|
587
|
+
|:---:|:---:|:---:|:---:|
|
588
|
+
|@mellowfish|@horacio|@dukex|@dark-panda|
|
589
|
+
|Spring Hill, TN|Buenos Aires|São Paulo||
|
590
|
+
|
502
591
|
## License
|
503
592
|
|
504
593
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -47,6 +47,9 @@ module ActionView
|
|
47
47
|
@view_flow ||= view_context.view_flow
|
48
48
|
@virtual_path ||= virtual_path
|
49
49
|
@variant = @lookup_context.variants.first
|
50
|
+
|
51
|
+
return "" unless render?
|
52
|
+
|
50
53
|
old_current_template = @current_template
|
51
54
|
@current_template = self
|
52
55
|
|
@@ -59,6 +62,10 @@ module ActionView
|
|
59
62
|
@current_template = old_current_template
|
60
63
|
end
|
61
64
|
|
65
|
+
def render?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
62
69
|
def initialize(*); end
|
63
70
|
|
64
71
|
def render(options = {}, args = {}, &block)
|
@@ -112,6 +119,12 @@ module ActionView
|
|
112
119
|
|
113
120
|
attr_reader :content, :view_context
|
114
121
|
|
122
|
+
# The controller used for testing components.
|
123
|
+
# Defaults to ApplicationController. This should be set early
|
124
|
+
# in the initialization process and should be set to a string.
|
125
|
+
mattr_accessor :test_controller
|
126
|
+
@@test_controller = "ApplicationController"
|
127
|
+
|
115
128
|
class << self
|
116
129
|
def inherited(child)
|
117
130
|
child.include Rails.application.routes.url_helpers unless child < Rails.application.routes.url_helpers
|
@@ -199,7 +212,7 @@ module ActionView
|
|
199
212
|
|
200
213
|
def matching_views_in_source_location
|
201
214
|
return [] unless source_location
|
202
|
-
(Dir["#{source_location.
|
215
|
+
(Dir["#{source_location.chomp(File.extname(source_location))}.*{#{ActionView::Template.template_handler_extensions.join(',')}}"] - [source_location])
|
203
216
|
end
|
204
217
|
|
205
218
|
def templates
|
@@ -6,10 +6,9 @@ module ActionView
|
|
6
6
|
module Component # :nodoc:
|
7
7
|
class Preview
|
8
8
|
extend ActiveSupport::DescendantsTracker
|
9
|
-
include ActionView::Component::TestHelpers
|
10
9
|
|
11
|
-
def render(component,
|
12
|
-
|
10
|
+
def render(component, **args, &block)
|
11
|
+
{ component: component, args: args, block: block }
|
13
12
|
end
|
14
13
|
|
15
14
|
class << self
|
@@ -19,21 +18,14 @@ module ActionView
|
|
19
18
|
descendants
|
20
19
|
end
|
21
20
|
|
22
|
-
# Returns the
|
23
|
-
def
|
24
|
-
|
25
|
-
if layout.nil?
|
26
|
-
layout = @layout.nil? ? "layouts/application" : @layout
|
27
|
-
end
|
28
|
-
|
29
|
-
Rails::ComponentExamplesController.render(template: "examples/show",
|
30
|
-
layout: layout,
|
31
|
-
assigns: { example: example_html })
|
21
|
+
# Returns the arguments for rendering of the component in its layout
|
22
|
+
def render_args(example)
|
23
|
+
new.public_send(example).merge(layout: @layout)
|
32
24
|
end
|
33
25
|
|
34
26
|
# Returns the component object class associated to the preview.
|
35
27
|
def component
|
36
|
-
|
28
|
+
name.chomp("Preview").constantize
|
37
29
|
end
|
38
30
|
|
39
31
|
# Returns all of the available examples for the component preview.
|
@@ -58,7 +50,7 @@ module ActionView
|
|
58
50
|
|
59
51
|
# Returns the underscored name of the component preview without the suffix.
|
60
52
|
def preview_name
|
61
|
-
name.
|
53
|
+
name.chomp("Preview").underscore
|
62
54
|
end
|
63
55
|
|
64
56
|
# Setter for layout name.
|
@@ -8,7 +8,7 @@ module ActionView
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def controller
|
11
|
-
@controller ||=
|
11
|
+
@controller ||= Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
|
12
12
|
end
|
13
13
|
|
14
14
|
def request
|
@@ -10,11 +10,11 @@ module Rails
|
|
10
10
|
check_class_collision suffix: "Component"
|
11
11
|
|
12
12
|
def create_component_file
|
13
|
-
template "component.rb", File.join("app/components",
|
13
|
+
template "component.rb", File.join("app/components", class_path, "#{file_name}_component.rb")
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_template_file
|
17
|
-
template "component.html.erb", File.join("app/components",
|
17
|
+
template "component.html.erb", File.join("app/components", class_path, "#{file_name}_component.html.erb")
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
@@ -6,7 +6,7 @@ module Rspec
|
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
7
7
|
|
8
8
|
def create_test_file
|
9
|
-
template "component_spec.rb", File.join("spec/components", "#{file_name}_component_spec.rb")
|
9
|
+
template "component_spec.rb", File.join("spec/components", class_path, "#{file_name}_component_spec.rb")
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -7,7 +7,7 @@ module TestUnit
|
|
7
7
|
check_class_collision suffix: "ComponentTest"
|
8
8
|
|
9
9
|
def create_test_file
|
10
|
-
template "component_test.rb", File.join("test/components", "#{file_name}_component_test.rb")
|
10
|
+
template "component_test.rb", File.join("test/components", class_path, "#{file_name}_component_test.rb")
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
data/lib/railties/lib/rails.rb
CHANGED
@@ -4,6 +4,7 @@ require "rails/application_controller"
|
|
4
4
|
|
5
5
|
class Rails::ComponentsController < Rails::ApplicationController # :nodoc:
|
6
6
|
prepend_view_path File.expand_path("templates/rails", __dir__)
|
7
|
+
prepend_view_path "#{Rails.root}/app/views/" if defined?(Rails.root)
|
7
8
|
|
8
9
|
around_action :set_locale, only: :previews
|
9
10
|
before_action :find_preview, only: :previews
|
@@ -25,7 +26,10 @@ class Rails::ComponentsController < Rails::ApplicationController # :nodoc:
|
|
25
26
|
render template: "components/previews"
|
26
27
|
else
|
27
28
|
@example_name = File.basename(params[:path])
|
28
|
-
|
29
|
+
@render_args = @preview.render_args(@example_name)
|
30
|
+
layout = @render_args[:layout]
|
31
|
+
opts = layout.nil? ? {} : { layout: layout }
|
32
|
+
render template: "components/preview", **opts
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
@@ -1 +1 @@
|
|
1
|
-
<%=
|
1
|
+
<%= render(@render_args[:component], **@render_args[:args], &@render_args[:block])%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionview-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,12 +163,10 @@ files:
|
|
163
163
|
- lib/rails/generators/test_unit/component_generator.rb
|
164
164
|
- lib/rails/generators/test_unit/templates/component_test.rb.tt
|
165
165
|
- lib/railties/lib/rails.rb
|
166
|
-
- lib/railties/lib/rails/component_examples_controller.rb
|
167
166
|
- lib/railties/lib/rails/components_controller.rb
|
168
167
|
- lib/railties/lib/rails/templates/rails/components/index.html.erb
|
169
168
|
- lib/railties/lib/rails/templates/rails/components/preview.html.erb
|
170
169
|
- lib/railties/lib/rails/templates/rails/components/previews.html.erb
|
171
|
-
- lib/railties/lib/rails/templates/rails/examples/show.html.erb
|
172
170
|
- script/bootstrap
|
173
171
|
- script/console
|
174
172
|
- script/install
|
@@ -1,9 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/application_controller"
|
4
|
-
load "config/application.rb" unless Rails.root
|
5
|
-
|
6
|
-
class Rails::ComponentExamplesController < ActionController::Base # :nodoc:
|
7
|
-
prepend_view_path File.expand_path("templates/rails", __dir__)
|
8
|
-
append_view_path Rails.root.join("app/views")
|
9
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= raw @example %>
|