dry-view 0.7.0 → 0.7.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 +4 -4
- data/CHANGELOG.md +75 -54
- data/LICENSE +20 -0
- data/README.md +19 -36
- data/dry-view.gemspec +24 -15
- data/lib/dry/view.rb +19 -12
- data/lib/dry/view/context.rb +3 -3
- data/lib/dry/view/decorated_attributes.rb +2 -1
- data/lib/dry/view/errors.rb +3 -1
- data/lib/dry/view/exposure.rb +21 -13
- data/lib/dry/view/exposures.rb +5 -3
- data/lib/dry/view/part.rb +15 -6
- data/lib/dry/view/part_builder.rb +8 -4
- data/lib/dry/view/path.rb +1 -1
- data/lib/dry/view/render_environment.rb +4 -4
- data/lib/dry/view/render_environment_missing.rb +4 -4
- data/lib/dry/view/rendered.rb +1 -1
- data/lib/dry/view/renderer.rb +1 -1
- data/lib/dry/view/scope.rb +21 -7
- data/lib/dry/view/scope_builder.rb +4 -4
- data/lib/dry/view/tilt.rb +1 -1
- data/lib/dry/view/tilt/erb.rb +1 -1
- data/lib/dry/view/tilt/erbse.rb +1 -1
- data/lib/dry/view/version.rb +1 -1
- metadata +46 -47
- data/.codeclimate.yml +0 -18
- data/.gitignore +0 -26
- data/.rspec +0 -2
- data/.travis.yml +0 -28
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -32
- data/LICENSE.md +0 -10
- data/Rakefile +0 -6
- data/bin/console +0 -7
- data/bin/setup +0 -5
- data/bin/setup_helpers.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e819c2e7fc0b6fe2aed059b2d63993b2e107e7d9b682652dc9a0dedefdf7458
|
4
|
+
data.tar.gz: e45c5c695005d30eb755ccffd22efc5bbdf7c91b018f4c2fe859cb6b015f70bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4797bca5d6dba8ba676794d9ff21c531c1ee303a0af87f924ee09e89c9faadc898f5b1dc9d24731c32e62d5b5c031efa4b6f8a7062ab30bd3f7ea4397eac7b2
|
7
|
+
data.tar.gz: 60fe4d2131720fd19cebe465283f06f05abb0247b094fc946ff96ac9b0b77c5962561ee68da1dd067876ace1d5def0caccdf18e7598a25800cf199aad5f36772
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,30 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
|
+
|
3
|
+
## 0.7.1 2021-02-08
|
4
|
+
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Template not found errors properly show configured paths (@adam12 in #144)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Compatible with Ruby 2.7/3.0 keyword argument handling (@flash-gordon in 4e7cefb)
|
13
|
+
- dry-equalizer dependency dropped in favor of dry-core (@solnic)
|
14
|
+
|
15
|
+
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-view/compare/v0.7.0...v0.7.1)
|
16
|
+
|
17
|
+
## 0.7.0 2019-03-06
|
18
|
+
|
2
19
|
|
3
20
|
### Added
|
4
21
|
|
5
22
|
- Raise a `Dry::View::UndefinedConfigError` when a view is called but no paths have been configured (timriley in [#130][pr130])
|
6
23
|
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Avoid a `SystemStackError` when a view is configured with a template that cannot be found on the filesystem (timriley in [#129][pr129])
|
27
|
+
|
7
28
|
### Changed
|
8
29
|
|
9
30
|
- [BREAKING] Move `Dry::View::Renderer::TemplateNotFoundError` to `Dry::View::TemplateNotFoundError` (timriley in [#130][pr130])
|
@@ -12,17 +33,10 @@
|
|
12
33
|
- Stop searching in `shared/` subdirectories when rendering a view's template (as opposed to partials) (timriley in [#130][pr130])
|
13
34
|
- Adjust template lookup cache keys to ensure no false hits (timriley in [#130][pr130])
|
14
35
|
|
15
|
-
### Fixed
|
16
|
-
|
17
|
-
- Avoid a `SystemStackError` when a view is configured with a template that cannot be found on the filesystem (timriley in [#129][pr129])
|
18
|
-
|
19
36
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-view/compare/v0.6.0...v0.7.0)
|
20
37
|
|
38
|
+
## 0.6.0 2019-01-30
|
21
39
|
|
22
|
-
[pr129]: https://github.com/dry-rb/dry-view/pull/129
|
23
|
-
[pr130]: https://github.com/dry-rb/dry-view/pull/130
|
24
|
-
|
25
|
-
# 0.6.0 / 2019-01-30
|
26
40
|
|
27
41
|
### Added
|
28
42
|
|
@@ -37,6 +51,10 @@
|
|
37
51
|
- Added "Tilt adapter" layer, to ensure a rendering engine compatible with dry-view's features is being used. Added adapters for "haml" and "erb" templates to ensure that "hamlit-block" and "erbse" are required and used as engines (unlike their more common counterparts, both of these engines support the implicit block capturing that is a central part of dry-view rendering behaviour) (timriley in [#106][pr106])
|
38
52
|
- Added `renderer_engine_mapping` setting to View, which allows an explicit engine class to be provided for the rendering of a given type of template (e.g. `config.renderer_engine_mapping = {erb: Tilt::ErubiTemplate}`) (timriley in [#106][pr106])
|
39
53
|
|
54
|
+
### Fixed
|
55
|
+
|
56
|
+
- Preserve renderer options when chdir-ing (timriley in [889ac7b](https://github.com/dry-rb/dry-view/commit/889ac7b))
|
57
|
+
|
40
58
|
### Changed
|
41
59
|
|
42
60
|
- [BREAKING] `Dry::View::Controller` renamed to `Dry::View` (timriley in [#115][pr115])
|
@@ -48,30 +66,9 @@
|
|
48
66
|
- Attribute decoration in `Part` now achieved via a prepended module, which means it is possible to decorate an attribute provided by an instance method directly on the part class, which wasn't possible with the previous `method_missing`-based approach (timriley in [#110][pr110])
|
49
67
|
- `Part` classes can be initialized with missing `name:` and `rendering:` values, which can be useful for unit testing Part methods that don't use any rendering facilities (timriley in [#116][pr116])
|
50
68
|
|
51
|
-
|
52
|
-
|
53
|
-
- Preserve renderer options when chdir-ing (timriley in [889ac7b](https://github.com/dry-rb/dry-view/commit/889ac7b))
|
69
|
+
[Compare v0.5.4...v0.6.0](https://github.com/dry-rb/dry-view/compare/v0.5.4...v0.6.0)
|
54
70
|
|
55
|
-
|
56
|
-
|
57
|
-
[pr72]: https://github.com/dry-rb/dry-view/pull/72
|
58
|
-
[pr80]: https://github.com/dry-rb/dry-view/pull/80
|
59
|
-
[pr86]: https://github.com/dry-rb/dry-view/pull/86
|
60
|
-
[pr87]: https://github.com/dry-rb/dry-view/pull/87
|
61
|
-
[pr88]: https://github.com/dry-rb/dry-view/pull/88
|
62
|
-
[pr89]: https://github.com/dry-rb/dry-view/pull/89
|
63
|
-
[pr90]: https://github.com/dry-rb/dry-view/pull/90
|
64
|
-
[pr91]: https://github.com/dry-rb/dry-view/pull/91
|
65
|
-
[pr97]: https://github.com/dry-rb/dry-view/pull/97
|
66
|
-
[pr98]: https://github.com/dry-rb/dry-view/pull/98
|
67
|
-
[pr106]: https://github.com/dry-rb/dry-view/pull/106
|
68
|
-
[pr110]: https://github.com/dry-rb/dry-view/pull/110
|
69
|
-
[pr115]: https://github.com/dry-rb/dry-view/pull/115
|
70
|
-
[pr116]: https://github.com/dry-rb/dry-view/pull/116
|
71
|
-
[pr118]: https://github.com/dry-rb/dry-view/pull/118
|
72
|
-
[pr119]: https://github.com/dry-rb/dry-view/pull/119
|
73
|
-
|
74
|
-
# 0.5.4 / 2019-01-06 [YANKED 2019-01-18]
|
71
|
+
## 0.5.4 2019-01-06
|
75
72
|
|
76
73
|
This version was yanked due to the release accidentally containing a batch of breaking changes from master.
|
77
74
|
|
@@ -79,7 +76,11 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
79
76
|
|
80
77
|
- Preserve renderer options when chdir-ing (timriley in [889ac7b](https://github.com/dry-rb/dry-view/commit/889ac7b))
|
81
78
|
|
82
|
-
|
79
|
+
|
80
|
+
[Compare v0.5.3...v0.5.4](https://github.com/dry-rb/dry-view/compare/v0.5.3...v0.5.4)
|
81
|
+
|
82
|
+
## 0.5.3 2018-10-22
|
83
|
+
|
83
84
|
|
84
85
|
### Added
|
85
86
|
|
@@ -91,10 +92,8 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
91
92
|
|
92
93
|
[Compare v0.5.2...v0.5.3](https://github.com/dry-rb/dry-view/compare/v0.5.2...v0.5.3)
|
93
94
|
|
94
|
-
|
95
|
-
[pr63]: https://github.com/dry-rb/dry-view/pull/63
|
95
|
+
## 0.5.2 2018-06-13
|
96
96
|
|
97
|
-
# 0.5.2 / 2018-06-13
|
98
97
|
|
99
98
|
### Changed
|
100
99
|
|
@@ -102,24 +101,29 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
102
101
|
|
103
102
|
[Compare v0.5.1...v0.5.2](https://github.com/dry-rb/dry-view/compare/v0.5.1...v0.5.2)
|
104
103
|
|
105
|
-
|
104
|
+
## 0.5.1 2018-02-20
|
105
|
+
|
106
106
|
|
107
107
|
### Added
|
108
108
|
|
109
109
|
- Exposures are inherited from parent view controller classes (GustavoCaso)
|
110
110
|
|
111
|
+
|
111
112
|
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-view/compare/v0.5.0...v0.5.1)
|
112
113
|
|
113
|
-
|
114
|
+
## 0.5.0 2018-01-23
|
115
|
+
|
114
116
|
|
115
117
|
### Added
|
116
118
|
|
117
119
|
- Support for parts with decorated attributes (timriley + GustavoCaso)
|
118
120
|
- Ability to easily create another part instance via `Part#new` (GustavoCaso)
|
119
121
|
|
122
|
+
|
120
123
|
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-view/compare/v0.4.0...v0.5.0)
|
121
124
|
|
122
|
-
|
125
|
+
## 0.4.0 2017-11-01
|
126
|
+
|
123
127
|
|
124
128
|
### Added
|
125
129
|
|
@@ -133,35 +137,52 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
133
137
|
- Allow `Dry::View::Part` instances to be created without explicitly passing a `renderer`. This is helpful for unit testing view parts that don't need to render anything (dNitza)
|
134
138
|
- Partials can be nested within additional sub-directories by rendering them their relative path as their name, e.g. `render(:"foo/bar")` will look for a `foo/_bar.html.slim` template within the normal template lookup paths (timriley)
|
135
139
|
|
136
|
-
|
140
|
+
[Compare v0.3.0...v0.4.0](https://github.com/dry-rb/dry-view/compare/v0.3.0...v0.4.0)
|
141
|
+
|
142
|
+
## 0.3.0 2017-05-14
|
137
143
|
|
138
144
|
This release reintroduces view parts in a more helpful form. You can provide your own custom view part classes to encapsulate your view logic, as well as a decorator for custom, shared behavior arouund view part wrapping.
|
139
145
|
|
146
|
+
### Added
|
147
|
+
|
148
|
+
- Wrap all values passed to the template in `Dry::View::Part` objects
|
149
|
+
- Added a `decorator` config to `Dry::View::Controller`, with a default `Dry::View::Decorator` that wraps the exposure values in `Dry::View::Part` objects (as above). Provide your own part classes by passing an `:as` option to your exposures, e.g. `expose :user, as: MyApp::UserPart`
|
150
|
+
|
140
151
|
### Changed
|
141
152
|
|
142
153
|
- [BREAKING] Partial rendering in templates requires an explicit `render` method call instead of method_missing behaviour usinig the partial's name (e.g. `<%= render :my_partial %>` instead of `<%= my_partial %>`)
|
143
154
|
|
144
|
-
|
155
|
+
[Compare v0.2.2...v0.3.0](https://github.com/dry-rb/dry-view/compare/v0.2.2...v0.3.0)
|
145
156
|
|
146
|
-
|
147
|
-
- Added a `decorator` config to `Dry::View::Controller`, with a default `Dry::View::Decorator` that wraps the exposure values in `Dry::View::Part` objects (as above). Provide your own part classes by passing an `:as` option to your exposures, e.g. `expose :user, as: MyApp::UserPart`
|
157
|
+
## 0.2.2 2017-01-31
|
148
158
|
|
149
|
-
# 0.2.2 / 2017-01-31
|
150
159
|
|
151
160
|
### Changed
|
152
161
|
|
153
162
|
- Make input passthrough exposures (when there is no block or matching instance metod) return nil instead of raise in the case of a missing input key (timriley)
|
154
163
|
|
155
|
-
|
164
|
+
[Compare v0.2.1...v0.2.2](https://github.com/dry-rb/dry-view/compare/v0.2.1...v0.2.2)
|
165
|
+
|
166
|
+
## 0.2.1 2017-01-30
|
167
|
+
|
156
168
|
|
157
169
|
### Fixed
|
158
170
|
|
159
171
|
- Exposure blocks now have access to the view controller instance when they're called (timriley)
|
160
172
|
|
161
|
-
|
173
|
+
|
174
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-view/compare/v0.2.0...v0.2.1)
|
175
|
+
|
176
|
+
## 0.2.0 2017-01-30
|
162
177
|
|
163
178
|
This release is a major reorientation for dry-view, and it should allow for more natural, straightforward template authoring.
|
164
179
|
|
180
|
+
### Added
|
181
|
+
|
182
|
+
- Will render templates using any Tilt-supported engine, based on the template's final file extension (e.g. `hello.html.slim` will use Slim). For thread-safety, be sure to explicitly require any engine gems you intend to use. (timriley)
|
183
|
+
- `expose` (and `expose_private`) `Dry::View::Controller` class methods allow you to more easily declare and prepare the data for your template (timriley)
|
184
|
+
- Added `Dry::View::Scope`, which is the scope used for rendering templates. This includes the data from the exposures along with the context object (timriley)
|
185
|
+
|
165
186
|
### Changed
|
166
187
|
|
167
188
|
- [BREAKING] `Dry::View::Layout` renamed to `Dry::View::Controller`. The "view controller" name better represents this object's job: to (timriley)
|
@@ -173,13 +194,10 @@ This release is a major reorientation for dry-view, and it should allow for more
|
|
173
194
|
- [BREAKING] With view parts removed, partials can only be rendered by top-level method calls within templates (timriley)
|
174
195
|
- Ruby version 2.1.0 is now the earliest supported version (timriley)
|
175
196
|
|
176
|
-
|
197
|
+
[Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-view/compare/v0.1.1...v0.2.0)
|
177
198
|
|
178
|
-
|
179
|
-
- `expose` (and `expose_private`) `Dry::View::Controller` class methods allow you to more easily declare and prepare the data for your template (timriley)
|
180
|
-
- Added `Dry::View::Scope`, which is the scope used for rendering templates. This includes the data from the exposures along with the context object (timriley)
|
199
|
+
## 0.1.1 2016-07-07
|
181
200
|
|
182
|
-
# 0.1.1 / 2016-07-07
|
183
201
|
|
184
202
|
### Changed
|
185
203
|
|
@@ -187,12 +205,15 @@ This release is a major reorientation for dry-view, and it should allow for more
|
|
187
205
|
- Render template content first, before passing that content to the layout. This makes "content_for"-style behaviours possible, where the template stores some data that the layout can then use later (timriley)
|
188
206
|
- Configure default template encoding to be UTF-8, fixing some issues with template rendering on deployed sites (gotar)
|
189
207
|
|
190
|
-
|
208
|
+
[Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-view/compare/v0.1.0...v0.1.1)
|
209
|
+
|
210
|
+
## 0.1.0 2016-03-28
|
211
|
+
|
191
212
|
|
192
213
|
### Added
|
193
214
|
|
194
|
-
– `Dry::View::Layout` supports multiple view template formats. Configure format/engine pairs (e.g. `{html: :slim, text: :erb}`) on the `formats` setting. The first format becomes the default. Request specific formats when calling the view, e.g. `my_view.call(format: :text)`.
|
215
|
+
- – `Dry::View::Layout` supports multiple view template formats. Configure format/engine pairs (e.g. `{html: :slim, text: :erb}`) on the `formats` setting. The first format becomes the default. Request specific formats when calling the view, e.g. `my_view.call(format: :text)`.
|
195
216
|
|
196
217
|
### Changed
|
197
218
|
|
198
|
-
– Extracted from rodakase and renamed to dry-view. `Rodakase::View` is now `Dry::View`.
|
219
|
+
- – Extracted from rodakase and renamed to dry-view. `Rodakase::View` is now `Dry::View`.
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2021 dry-rb team
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,46 +1,29 @@
|
|
1
|
-
|
1
|
+
[gem]: https://rubygems.org/gems/dry-view
|
2
|
+
[actions]: https://github.com/dry-rb/dry-view/actions
|
3
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-view
|
4
|
+
[chat]: https://dry-rb.zulipchat.com
|
5
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-view
|
2
6
|
|
3
|
-
[][travis]
|
5
|
-
[][maint]
|
6
|
-
[][cov]
|
7
|
-
[][inch]
|
7
|
+
# dry-view [][chat]
|
8
8
|
|
9
|
-
dry-view
|
10
|
-
|
9
|
+
[][gem]
|
10
|
+
[][actions]
|
11
|
+
[][codacy]
|
12
|
+
[][codacy]
|
13
|
+
[][inchpages]
|
11
14
|
|
12
15
|
## Links
|
13
16
|
|
14
|
-
* [
|
15
|
-
* [API documentation]
|
16
|
-
* [dry-rb website][website]
|
17
|
-
* [Support forum][support]
|
18
|
-
|
19
|
-
## Development
|
20
|
-
|
21
|
-
After checking out this repo, run `bin/setup` to setup the project.
|
17
|
+
* [User documentation](http://dry-rb.org/gems/dry-view)
|
18
|
+
* [API documentation](http://rubydoc.info/gems/dry-view)
|
22
19
|
|
23
|
-
|
20
|
+
## Supported Ruby versions
|
24
21
|
|
25
|
-
|
22
|
+
This library officially supports the following Ruby versions:
|
26
23
|
|
27
|
-
|
24
|
+
* MRI >= `2.5`
|
25
|
+
* jruby >= `9.2`
|
28
26
|
|
29
|
-
|
30
|
-
development, we recommend having a discussion [in the forum][support] before
|
31
|
-
beginning your work.
|
27
|
+
## License
|
32
28
|
|
33
|
-
|
34
|
-
[docs]: https://dry-rb.org/gems/dry-view
|
35
|
-
[api]: https://www.rubydoc.info/github/dry-rb/dry-view
|
36
|
-
[website]: https://dry-rb.org/
|
37
|
-
[support]: https://discourse.dry-rb.org/
|
38
|
-
[repo]: https://github.com/dry-rb/dry-view
|
39
|
-
|
40
|
-
<!-- Badge links -->
|
41
|
-
[gitter]: https://gitter.im/dry-rb/chat
|
42
|
-
[gem]: https://rubygems.org/gems/dry-view
|
43
|
-
[travis]: https://travis-ci.org/dry-rb/dry-view
|
44
|
-
[maint]: https://codeclimate.com/github/dry-rb/dry-view/maintainability
|
45
|
-
[cov]: https://codeclimate.com/github/dry-rb/dry-view/test_coverage
|
46
|
-
[inch]: http://inch-ci.org/github/dry-rb/dry-view
|
29
|
+
See `LICENSE` file.
|
data/dry-view.gemspec
CHANGED
@@ -1,31 +1,40 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# this file is managed by dry-rb/devtools project
|
3
|
+
|
4
|
+
lib = File.expand_path('lib', __dir__)
|
2
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
6
|
require 'dry/view/version'
|
4
7
|
|
5
8
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
7
|
-
spec.version = Dry::View::VERSION
|
9
|
+
spec.name = 'dry-view'
|
8
10
|
spec.authors = ["Tim Riley", "Piotr Solnica"]
|
9
11
|
spec.email = ["tim@icelab.com.au", "piotr.solnica@gmail.com"]
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.version = Dry::View::VERSION.dup
|
14
|
+
|
10
15
|
spec.summary = "A complete, standalone view rendering system that gives you everything you need to write well-factored view code"
|
11
16
|
spec.description = spec.summary
|
12
|
-
spec.homepage =
|
13
|
-
spec.
|
17
|
+
spec.homepage = 'https://dry-rb.org/gems/dry-view'
|
18
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-view.gemspec", "lib/**/*"]
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = []
|
21
|
+
spec.require_paths = ['lib']
|
14
22
|
|
15
|
-
spec.
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
23
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
24
|
+
spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-view/blob/master/CHANGELOG.md'
|
25
|
+
spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-view'
|
26
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-view/issues'
|
19
27
|
|
20
|
-
spec.required_ruby_version =
|
28
|
+
spec.required_ruby_version = ">= 2.5.0"
|
21
29
|
|
22
|
-
|
23
|
-
spec.add_runtime_dependency "
|
30
|
+
# to update dependencies edit project.yml
|
31
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
24
32
|
spec.add_runtime_dependency "dry-configurable", "~> 0.1"
|
25
|
-
spec.add_runtime_dependency "dry-
|
33
|
+
spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
|
26
34
|
spec.add_runtime_dependency "dry-inflector", "~> 0.1"
|
35
|
+
spec.add_runtime_dependency "tilt", "~> 2.0", ">= 2.0.6"
|
27
36
|
|
28
37
|
spec.add_development_dependency "bundler"
|
29
|
-
spec.add_development_dependency "rake"
|
30
|
-
spec.add_development_dependency "rspec"
|
38
|
+
spec.add_development_dependency "rake"
|
39
|
+
spec.add_development_dependency "rspec"
|
31
40
|
end
|
data/lib/dry/view.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "dry/configurable"
|
4
4
|
require "dry/core/cache"
|
5
|
-
require "dry/equalizer"
|
5
|
+
require "dry/core/equalizer"
|
6
6
|
require "dry/inflector"
|
7
7
|
|
8
8
|
require_relative "view/context"
|
@@ -230,8 +230,10 @@ module Dry
|
|
230
230
|
# @!macro [new] exposure_options
|
231
231
|
# @param options [Hash] the exposure's options
|
232
232
|
# @option options [Boolean] :layout expose this value to the layout (defaults to false)
|
233
|
-
# @option options [Boolean] :decorate decorate this value in a matching Part (defaults to
|
234
|
-
#
|
233
|
+
# @option options [Boolean] :decorate decorate this value in a matching Part (defaults to
|
234
|
+
# true)
|
235
|
+
# @option options [Symbol, Class] :as an alternative name or class to use when finding a
|
236
|
+
# matching Part
|
235
237
|
|
236
238
|
# @overload expose(name, **options, &block)
|
237
239
|
# Define a value to be passed to the template. The return value of the
|
@@ -315,7 +317,8 @@ module Dry
|
|
315
317
|
#
|
316
318
|
# @param name [Symbol] name for the exposure
|
317
319
|
# @macro exposure_options
|
318
|
-
# @option options [Boolean] :default a default value to provide if there is no matching
|
320
|
+
# @option options [Boolean] :default a default value to provide if there is no matching
|
321
|
+
# input data
|
319
322
|
#
|
320
323
|
# @overload expose(*names, **options)
|
321
324
|
# Define multiple values to pass through from the input data (when there
|
@@ -326,17 +329,18 @@ module Dry
|
|
326
329
|
#
|
327
330
|
# @param names [Symbol] names for the exposures
|
328
331
|
# @macro exposure_options
|
329
|
-
# @option options [Boolean] :default a default value to provide if there is no matching
|
332
|
+
# @option options [Boolean] :default a default value to provide if there is no matching
|
333
|
+
# input data
|
330
334
|
#
|
331
335
|
# @see https://dry-rb.org/gems/dry-view/exposures/
|
332
336
|
#
|
333
337
|
# @api public
|
334
338
|
def self.expose(*names, **options, &block)
|
335
339
|
if names.length == 1
|
336
|
-
exposures.add(names.first, block, options)
|
340
|
+
exposures.add(names.first, block, **options)
|
337
341
|
else
|
338
342
|
names.each do |name|
|
339
|
-
exposures.add(name, options)
|
343
|
+
exposures.add(name, **options)
|
340
344
|
end
|
341
345
|
end
|
342
346
|
end
|
@@ -411,7 +415,7 @@ module Dry
|
|
411
415
|
config.paths,
|
412
416
|
format: format,
|
413
417
|
engine_mapping: config.renderer_engine_mapping,
|
414
|
-
**config.renderer_options
|
418
|
+
**config.renderer_options
|
415
419
|
)
|
416
420
|
}
|
417
421
|
end
|
@@ -467,7 +471,10 @@ module Dry
|
|
467
471
|
|
468
472
|
if layout?
|
469
473
|
layout_env = self.class.layout_env(format: format, context: context)
|
470
|
-
output = env.template(
|
474
|
+
output = env.template(
|
475
|
+
self.class.layout_path,
|
476
|
+
layout_env.scope(config.scope, layout_locals(locals))
|
477
|
+
) { output }
|
471
478
|
end
|
472
479
|
|
473
480
|
Rendered.new(output: output, locals: locals)
|
@@ -477,8 +484,8 @@ module Dry
|
|
477
484
|
|
478
485
|
# @api private
|
479
486
|
def ensure_config
|
480
|
-
raise UndefinedConfigError
|
481
|
-
raise UndefinedConfigError
|
487
|
+
raise UndefinedConfigError, :paths unless Array(config.paths).any?
|
488
|
+
raise UndefinedConfigError, :template unless config.template
|
482
489
|
end
|
483
490
|
|
484
491
|
# @api private
|
@@ -501,7 +508,7 @@ module Dry
|
|
501
508
|
|
502
509
|
# @api private
|
503
510
|
def layout?
|
504
|
-
!!config.layout
|
511
|
+
!!config.layout # rubocop:disable Style/DoubleNegation
|
505
512
|
end
|
506
513
|
end
|
507
514
|
end
|