view_component 2.15.0 → 2.16.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.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +19 -9
- data/lib/rails/generators/erb/component_generator.rb +10 -1
- data/lib/rails/generators/haml/component_generator.rb +10 -1
- data/lib/rails/generators/slim/component_generator.rb +10 -1
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ccdcdb195fbc49953c3663294a7345eb012f88344d1375456a07c6ef781b1d8
|
4
|
+
data.tar.gz: b2cf7cb1139e318f2ca7712242e610c31a42c78448a5d3151db1550a41e00355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72657816a14d62166791f37d2f83cfd81efe8f186678bcf21e40c50d38d64663fbc4e2b9fe881820ba26f2a7ea258d5d6c0cb47a73132d5443f66db3489d1921
|
7
|
+
data.tar.gz: e7abe1071862dfb3208e2615176fd352b0f6cd6e7ef947b1dfb4528e435682908cd01ab8091b33612b234eebf7121a7dd00e5cb8890bc6ae1160fdf5bcbdcd3f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -341,15 +341,25 @@ As an alternative, views and other assets can be placed in a sidecar directory w
|
|
341
341
|
```
|
342
342
|
app/components
|
343
343
|
├── ...
|
344
|
-
├──
|
345
|
-
├──
|
346
|
-
| ├──
|
347
|
-
| ├──
|
348
|
-
| └──
|
344
|
+
├── example_component.rb
|
345
|
+
├── example_component
|
346
|
+
| ├── example_component.css
|
347
|
+
| ├── example_component.html.erb
|
348
|
+
| └── example_component.js
|
349
349
|
├── ...
|
350
350
|
|
351
351
|
```
|
352
352
|
|
353
|
+
To generate a component with a sidecar directory, use the `--sidecar` flag:
|
354
|
+
|
355
|
+
```
|
356
|
+
bin/rails generate component Example title content --sidecar
|
357
|
+
invoke test_unit
|
358
|
+
create test/components/example_component_test.rb
|
359
|
+
create app/components/example_component.rb
|
360
|
+
create app/components/example_component/example_component.html.erb
|
361
|
+
```
|
362
|
+
|
353
363
|
### Conditional Rendering
|
354
364
|
|
355
365
|
Components can implement a `#render?` method to be called after initialization to determine if the component should render.
|
@@ -980,10 +990,10 @@ ViewComponent is built by:
|
|
980
990
|
|@maxbeizer|@franco|@tbroad-ramsey|@jensljungblad|@bbugh|
|
981
991
|
|Nashville, TN|Switzerland|Spring Hill, TN|New York, NY|Austin, TX|
|
982
992
|
|
983
|
-
|<img src="https://avatars.githubusercontent.com/johannesengl?s=256" alt="johannesengl" width="128" />|<img src="https://avatars.githubusercontent.com/czj?s=256" alt="czj" width="128" />|
|
984
|
-
|
985
|
-
|@johannesengl|@czj|
|
986
|
-
|Berlin, Germany|Paris, France|
|
993
|
+
|<img src="https://avatars.githubusercontent.com/johannesengl?s=256" alt="johannesengl" width="128" />|<img src="https://avatars.githubusercontent.com/czj?s=256" alt="czj" width="128" />|<img src="https://avatars.githubusercontent.com/mrrooijen?s=256" alt="mrrooijen" width="128" />|
|
994
|
+
|:---:|:---:|:---:|
|
995
|
+
|@johannesengl|@czj|@mrrooijen|
|
996
|
+
|Berlin, Germany|Paris, France|The Netherlands|
|
987
997
|
|
988
998
|
## License
|
989
999
|
|
@@ -6,13 +6,22 @@ module Erb
|
|
6
6
|
module Generators
|
7
7
|
class ComponentGenerator < Base
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
9
|
+
class_option :sidecar, type: :boolean, default: false
|
9
10
|
|
10
11
|
def copy_view_file
|
11
|
-
template "component.html.erb",
|
12
|
+
template "component.html.erb", destination
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
17
|
+
def destination
|
18
|
+
if options["sidecar"]
|
19
|
+
File.join("app/components", class_path, "#{file_name}_component", "#{file_name}_component.html.erb")
|
20
|
+
else
|
21
|
+
File.join("app/components", class_path, "#{file_name}_component.html.erb")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def file_name
|
17
26
|
@_file_name ||= super.sub(/_component\z/i, "")
|
18
27
|
end
|
@@ -6,13 +6,22 @@ module Haml
|
|
6
6
|
module Generators
|
7
7
|
class ComponentGenerator < Erb::Generators::ComponentGenerator
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
9
|
+
class_option :sidecar, type: :boolean, default: false
|
9
10
|
|
10
11
|
def copy_view_file
|
11
|
-
template "component.html.haml",
|
12
|
+
template "component.html.haml", destination
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
17
|
+
def destination
|
18
|
+
if options["sidecar"]
|
19
|
+
File.join("app/components", class_path, "#{file_name}_component", "#{file_name}_component.html.haml")
|
20
|
+
else
|
21
|
+
File.join("app/components", class_path, "#{file_name}_component.html.haml")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def file_name
|
17
26
|
@_file_name ||= super.sub(/_component\z/i, "")
|
18
27
|
end
|
@@ -6,13 +6,22 @@ module Slim
|
|
6
6
|
module Generators
|
7
7
|
class ComponentGenerator < Erb::Generators::ComponentGenerator
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
9
|
+
class_option :sidecar, type: :boolean, default: false
|
9
10
|
|
10
11
|
def copy_view_file
|
11
|
-
template "component.html.slim",
|
12
|
+
template "component.html.slim", destination
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
17
|
+
def destination
|
18
|
+
if options["sidecar"]
|
19
|
+
File.join("app/components", class_path, "#{file_name}_component", "#{file_name}_component.html.slim")
|
20
|
+
else
|
21
|
+
File.join("app/components", class_path, "#{file_name}_component.html.slim")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
16
25
|
def file_name
|
17
26
|
@_file_name ||= super.sub(/_component\z/i, "")
|
18
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|