dry-view 0.7.0 → 0.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/CHANGELOG.md +88 -54
- data/LICENSE +20 -0
- data/README.md +13 -37
- data/dry-view.gemspec +24 -14
- 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 +22 -16
- data/lib/dry/view/exposures.rb +4 -3
- data/lib/dry/view/part.rb +12 -6
- data/lib/dry/view/part_builder.rb +6 -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/erb.rb +1 -1
- data/lib/dry/view/tilt/erbse.rb +1 -1
- data/lib/dry/view/tilt/haml.rb +3 -3
- data/lib/dry/view/tilt.rb +1 -1
- data/lib/dry/view/version.rb +1 -1
- data/lib/dry/view.rb +27 -20
- 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: 70b00212a774fa6075ff58086540e985cfeb251a1888faa349d219f27760c2eb
|
4
|
+
data.tar.gz: 29c6c92656d5ba45b0707404e87dfa7526ae61550cb8acf7b5a038ba2b071649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7e323b9a836df03ad6913341d2d59c69ce3f48c90fa232094e52fe70b3151e487a7607ffdac56d2a7e94e5ab5b6a72278e10670f226c7acbb0090e40887a416
|
7
|
+
data.tar.gz: b3a239a7d852536a3b5fb719b24f9c2cd867b5390232b975a7d497747cce1056ddb65ddedc47e91dc5a486c0833c03af1d9ffeac9271a68d7e4bfbef15c1adc2
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,43 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
|
+
|
3
|
+
## 0.8.0 2024-11-20
|
4
|
+
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Fix dry-configurable warnings (@olegykz in #153)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Require hamlit instead of hamlit/block (@olegykz in #155)
|
13
|
+
|
14
|
+
[Compare v0.7.1...v0.8.0](https://github.com/dry-rb/dry-view/compare/v0.7.1...v0.8.0)
|
15
|
+
|
16
|
+
## 0.7.1 2021-02-08
|
17
|
+
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- Template not found errors properly show configured paths (@adam12 in #144)
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Compatible with Ruby 2.7/3.0 keyword argument handling (@flash-gordon in 4e7cefb)
|
26
|
+
- dry-equalizer dependency dropped in favor of dry-core (@solnic)
|
27
|
+
|
28
|
+
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-view/compare/v0.7.0...v0.7.1)
|
29
|
+
|
30
|
+
## 0.7.0 2019-03-06
|
31
|
+
|
2
32
|
|
3
33
|
### Added
|
4
34
|
|
5
35
|
- Raise a `Dry::View::UndefinedConfigError` when a view is called but no paths have been configured (timriley in [#130][pr130])
|
6
36
|
|
37
|
+
### Fixed
|
38
|
+
|
39
|
+
- Avoid a `SystemStackError` when a view is configured with a template that cannot be found on the filesystem (timriley in [#129][pr129])
|
40
|
+
|
7
41
|
### Changed
|
8
42
|
|
9
43
|
- [BREAKING] Move `Dry::View::Renderer::TemplateNotFoundError` to `Dry::View::TemplateNotFoundError` (timriley in [#130][pr130])
|
@@ -12,17 +46,10 @@
|
|
12
46
|
- Stop searching in `shared/` subdirectories when rendering a view's template (as opposed to partials) (timriley in [#130][pr130])
|
13
47
|
- Adjust template lookup cache keys to ensure no false hits (timriley in [#130][pr130])
|
14
48
|
|
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
49
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-view/compare/v0.6.0...v0.7.0)
|
20
50
|
|
51
|
+
## 0.6.0 2019-01-30
|
21
52
|
|
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
53
|
|
27
54
|
### Added
|
28
55
|
|
@@ -37,6 +64,10 @@
|
|
37
64
|
- 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
65
|
- 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
66
|
|
67
|
+
### Fixed
|
68
|
+
|
69
|
+
- Preserve renderer options when chdir-ing (timriley in [889ac7b](https://github.com/dry-rb/dry-view/commit/889ac7b))
|
70
|
+
|
40
71
|
### Changed
|
41
72
|
|
42
73
|
- [BREAKING] `Dry::View::Controller` renamed to `Dry::View` (timriley in [#115][pr115])
|
@@ -48,30 +79,9 @@
|
|
48
79
|
- 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
80
|
- `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
81
|
|
51
|
-
|
82
|
+
[Compare v0.5.4...v0.6.0](https://github.com/dry-rb/dry-view/compare/v0.5.4...v0.6.0)
|
52
83
|
|
53
|
-
|
54
|
-
|
55
|
-
[Compare v0.5.3...v0.6.0](https://github.com/dry-rb/dry-view/compare/v0.5.3...v0.6.0)
|
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]
|
84
|
+
## 0.5.4 2019-01-06
|
75
85
|
|
76
86
|
This version was yanked due to the release accidentally containing a batch of breaking changes from master.
|
77
87
|
|
@@ -79,7 +89,11 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
79
89
|
|
80
90
|
- Preserve renderer options when chdir-ing (timriley in [889ac7b](https://github.com/dry-rb/dry-view/commit/889ac7b))
|
81
91
|
|
82
|
-
|
92
|
+
|
93
|
+
[Compare v0.5.3...v0.5.4](https://github.com/dry-rb/dry-view/compare/v0.5.3...v0.5.4)
|
94
|
+
|
95
|
+
## 0.5.3 2018-10-22
|
96
|
+
|
83
97
|
|
84
98
|
### Added
|
85
99
|
|
@@ -91,10 +105,8 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
91
105
|
|
92
106
|
[Compare v0.5.2...v0.5.3](https://github.com/dry-rb/dry-view/compare/v0.5.2...v0.5.3)
|
93
107
|
|
94
|
-
|
95
|
-
[pr63]: https://github.com/dry-rb/dry-view/pull/63
|
108
|
+
## 0.5.2 2018-06-13
|
96
109
|
|
97
|
-
# 0.5.2 / 2018-06-13
|
98
110
|
|
99
111
|
### Changed
|
100
112
|
|
@@ -102,24 +114,29 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
102
114
|
|
103
115
|
[Compare v0.5.1...v0.5.2](https://github.com/dry-rb/dry-view/compare/v0.5.1...v0.5.2)
|
104
116
|
|
105
|
-
|
117
|
+
## 0.5.1 2018-02-20
|
118
|
+
|
106
119
|
|
107
120
|
### Added
|
108
121
|
|
109
122
|
- Exposures are inherited from parent view controller classes (GustavoCaso)
|
110
123
|
|
124
|
+
|
111
125
|
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-view/compare/v0.5.0...v0.5.1)
|
112
126
|
|
113
|
-
|
127
|
+
## 0.5.0 2018-01-23
|
128
|
+
|
114
129
|
|
115
130
|
### Added
|
116
131
|
|
117
132
|
- Support for parts with decorated attributes (timriley + GustavoCaso)
|
118
133
|
- Ability to easily create another part instance via `Part#new` (GustavoCaso)
|
119
134
|
|
135
|
+
|
120
136
|
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-view/compare/v0.4.0...v0.5.0)
|
121
137
|
|
122
|
-
|
138
|
+
## 0.4.0 2017-11-01
|
139
|
+
|
123
140
|
|
124
141
|
### Added
|
125
142
|
|
@@ -133,35 +150,52 @@ This version was yanked due to the release accidentally containing a batch of br
|
|
133
150
|
- 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
151
|
- 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
152
|
|
136
|
-
|
153
|
+
[Compare v0.3.0...v0.4.0](https://github.com/dry-rb/dry-view/compare/v0.3.0...v0.4.0)
|
154
|
+
|
155
|
+
## 0.3.0 2017-05-14
|
137
156
|
|
138
157
|
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
158
|
|
159
|
+
### Added
|
160
|
+
|
161
|
+
- Wrap all values passed to the template in `Dry::View::Part` objects
|
162
|
+
- 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`
|
163
|
+
|
140
164
|
### Changed
|
141
165
|
|
142
166
|
- [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
167
|
|
144
|
-
|
168
|
+
[Compare v0.2.2...v0.3.0](https://github.com/dry-rb/dry-view/compare/v0.2.2...v0.3.0)
|
145
169
|
|
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`
|
170
|
+
## 0.2.2 2017-01-31
|
148
171
|
|
149
|
-
# 0.2.2 / 2017-01-31
|
150
172
|
|
151
173
|
### Changed
|
152
174
|
|
153
175
|
- 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
176
|
|
155
|
-
|
177
|
+
[Compare v0.2.1...v0.2.2](https://github.com/dry-rb/dry-view/compare/v0.2.1...v0.2.2)
|
178
|
+
|
179
|
+
## 0.2.1 2017-01-30
|
180
|
+
|
156
181
|
|
157
182
|
### Fixed
|
158
183
|
|
159
184
|
- Exposure blocks now have access to the view controller instance when they're called (timriley)
|
160
185
|
|
161
|
-
|
186
|
+
|
187
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-view/compare/v0.2.0...v0.2.1)
|
188
|
+
|
189
|
+
## 0.2.0 2017-01-30
|
162
190
|
|
163
191
|
This release is a major reorientation for dry-view, and it should allow for more natural, straightforward template authoring.
|
164
192
|
|
193
|
+
### Added
|
194
|
+
|
195
|
+
- 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)
|
196
|
+
- `expose` (and `expose_private`) `Dry::View::Controller` class methods allow you to more easily declare and prepare the data for your template (timriley)
|
197
|
+
- 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)
|
198
|
+
|
165
199
|
### Changed
|
166
200
|
|
167
201
|
- [BREAKING] `Dry::View::Layout` renamed to `Dry::View::Controller`. The "view controller" name better represents this object's job: to (timriley)
|
@@ -173,13 +207,10 @@ This release is a major reorientation for dry-view, and it should allow for more
|
|
173
207
|
- [BREAKING] With view parts removed, partials can only be rendered by top-level method calls within templates (timriley)
|
174
208
|
- Ruby version 2.1.0 is now the earliest supported version (timriley)
|
175
209
|
|
176
|
-
|
210
|
+
[Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-view/compare/v0.1.1...v0.2.0)
|
177
211
|
|
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)
|
212
|
+
## 0.1.1 2016-07-07
|
181
213
|
|
182
|
-
# 0.1.1 / 2016-07-07
|
183
214
|
|
184
215
|
### Changed
|
185
216
|
|
@@ -187,12 +218,15 @@ This release is a major reorientation for dry-view, and it should allow for more
|
|
187
218
|
- 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
219
|
- Configure default template encoding to be UTF-8, fixing some issues with template rendering on deployed sites (gotar)
|
189
220
|
|
190
|
-
|
221
|
+
[Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-view/compare/v0.1.0...v0.1.1)
|
222
|
+
|
223
|
+
## 0.1.0 2016-03-28
|
224
|
+
|
191
225
|
|
192
226
|
### Added
|
193
227
|
|
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)`.
|
228
|
+
- – `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
229
|
|
196
230
|
### Changed
|
197
231
|
|
198
|
-
– Extracted from rodakase and renamed to dry-view. `Rodakase::View` is now `Dry::View`.
|
232
|
+
- – 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-2023 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,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
[
|
4
|
-
[][travis]
|
5
|
-
[][maint]
|
6
|
-
[][cov]
|
7
|
-
[][inch]
|
1
|
+
<!--- this file is synced from dry-rb/template-gem project -->
|
2
|
+
[gem]: https://rubygems.org/gems/dry-view
|
3
|
+
[actions]: https://github.com/dry-rb/dry-view/actions
|
8
4
|
|
9
|
-
dry-view
|
10
|
-
everything you need to write well-factored view code.
|
5
|
+
# dry-view [][gem] [][actions]
|
11
6
|
|
12
7
|
## Links
|
13
8
|
|
14
|
-
* [
|
15
|
-
* [API documentation]
|
16
|
-
* [dry-rb
|
17
|
-
* [Support forum][support]
|
18
|
-
|
19
|
-
## Development
|
9
|
+
* [User documentation](https://dry-rb.org/gems/dry-view)
|
10
|
+
* [API documentation](http://rubydoc.info/gems/dry-view)
|
11
|
+
* [Forum](https://discourse.dry-rb.org)
|
20
12
|
|
21
|
-
|
13
|
+
## Supported Ruby versions
|
22
14
|
|
23
|
-
|
15
|
+
This library officially supports the following Ruby versions:
|
24
16
|
|
25
|
-
|
17
|
+
* MRI `>= 3.0.0`
|
18
|
+
* jruby `>= 9.4` (not tested on CI)
|
26
19
|
|
27
|
-
##
|
20
|
+
## License
|
28
21
|
|
29
|
-
|
30
|
-
development, we recommend having a discussion [in the forum][support] before
|
31
|
-
beginning your work.
|
32
|
-
|
33
|
-
<!-- Links -->
|
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
|
22
|
+
See `LICENSE` file.
|
data/dry-view.gemspec
CHANGED
@@ -1,31 +1,41 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# this file is synced from dry-rb/template-gem project
|
4
|
+
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
2
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
7
|
+
require "dry/view/version"
|
4
8
|
|
5
9
|
Gem::Specification.new do |spec|
|
6
10
|
spec.name = "dry-view"
|
7
|
-
spec.version = Dry::View::VERSION
|
8
11
|
spec.authors = ["Tim Riley", "Piotr Solnica"]
|
9
12
|
spec.email = ["tim@icelab.com.au", "piotr.solnica@gmail.com"]
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.version = Dry::View::VERSION.dup
|
15
|
+
|
10
16
|
spec.summary = "A complete, standalone view rendering system that gives you everything you need to write well-factored view code"
|
11
17
|
spec.description = spec.summary
|
12
18
|
spec.homepage = "https://dry-rb.org/gems/dry-view"
|
13
|
-
spec.
|
14
|
-
|
15
|
-
spec.
|
16
|
-
spec.bindir = "exe"
|
17
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-view.gemspec", "lib/**/*"]
|
20
|
+
spec.bindir = "bin"
|
21
|
+
spec.executables = []
|
18
22
|
spec.require_paths = ["lib"]
|
19
23
|
|
20
|
-
spec.
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-view/blob/main/CHANGELOG.md"
|
26
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-view"
|
27
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-view/issues"
|
21
28
|
|
22
|
-
spec.
|
23
|
-
|
29
|
+
spec.required_ruby_version = ">= 3.0.0"
|
30
|
+
|
31
|
+
# to update dependencies edit project.yml
|
32
|
+
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
24
33
|
spec.add_runtime_dependency "dry-configurable", "~> 0.1"
|
25
|
-
spec.add_runtime_dependency "dry-
|
34
|
+
spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9"
|
26
35
|
spec.add_runtime_dependency "dry-inflector", "~> 0.1"
|
36
|
+
spec.add_runtime_dependency "tilt", "~> 2.0", ">= 2.0.6"
|
27
37
|
|
28
38
|
spec.add_development_dependency "bundler"
|
29
|
-
spec.add_development_dependency "rake"
|
30
|
-
spec.add_development_dependency "rspec"
|
39
|
+
spec.add_development_dependency "rake"
|
40
|
+
spec.add_development_dependency "rspec"
|
31
41
|
end
|
data/lib/dry/view/context.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/equalizer"
|
3
|
+
require "dry/core/equalizer"
|
4
4
|
require_relative "decorated_attributes"
|
5
5
|
|
6
6
|
module Dry
|
@@ -43,7 +43,7 @@ module Dry
|
|
43
43
|
|
44
44
|
# @api private
|
45
45
|
def for_render_env(render_env)
|
46
|
-
return self if render_env ==
|
46
|
+
return self if render_env == _render_env
|
47
47
|
|
48
48
|
self.class.new(**_options.merge(render_env: render_env))
|
49
49
|
end
|
@@ -72,7 +72,7 @@ module Dry
|
|
72
72
|
def with(**new_options)
|
73
73
|
self.class.new(
|
74
74
|
render_env: _render_env,
|
75
|
-
**_options.merge(new_options)
|
75
|
+
**_options.merge(new_options)
|
76
76
|
)
|
77
77
|
end
|
78
78
|
end
|
@@ -27,7 +27,8 @@ module Dry
|
|
27
27
|
#
|
28
28
|
# @param names [Array<Symbol>] the attribute names
|
29
29
|
# @param options [Hash] the options to pass to the Part Builder
|
30
|
-
# @option options [Symbol, Class] :as an alternative name or class to use when finding a
|
30
|
+
# @option options [Symbol, Class] :as an alternative name or class to use when finding a
|
31
|
+
# matching Part
|
31
32
|
#
|
32
33
|
# @api public
|
33
34
|
def decorate(*names, **options)
|
data/lib/dry/view/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Dry
|
2
4
|
class View
|
3
5
|
# Error raised when critical settings are not configured
|
@@ -17,7 +19,7 @@ module Dry
|
|
17
19
|
def initialize(template_name, lookup_paths)
|
18
20
|
msg = [
|
19
21
|
"Template +#{template_name}+ could not be found in paths:",
|
20
|
-
lookup_paths.map { |path| " - #{path}"}
|
22
|
+
lookup_paths.map { |path| " - #{path}" }
|
21
23
|
].join("\n\n")
|
22
24
|
|
23
25
|
super(msg)
|
data/lib/dry/view/exposure.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry
|
3
|
+
require "dry/core/equalizer"
|
4
4
|
|
5
5
|
module Dry
|
6
6
|
class View
|
@@ -10,8 +10,8 @@ module Dry
|
|
10
10
|
class Exposure
|
11
11
|
include Dry::Equalizer(:name, :proc, :object, :options)
|
12
12
|
|
13
|
-
EXPOSURE_DEPENDENCY_PARAMETER_TYPES = [
|
14
|
-
INPUT_PARAMETER_TYPES = [
|
13
|
+
EXPOSURE_DEPENDENCY_PARAMETER_TYPES = %i[req opt].freeze
|
14
|
+
INPUT_PARAMETER_TYPES = %i[key keyreq keyrest].freeze
|
15
15
|
|
16
16
|
attr_reader :name
|
17
17
|
attr_reader :proc
|
@@ -26,7 +26,7 @@ module Dry
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def bind(obj)
|
29
|
-
self.class.new(name, proc, obj, options)
|
29
|
+
self.class.new(name, proc, obj, **options)
|
30
30
|
end
|
31
31
|
|
32
32
|
def dependency_names
|
@@ -50,15 +50,15 @@ module Dry
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def for_layout?
|
53
|
-
options.fetch(:layout
|
53
|
+
options.fetch(:layout, false)
|
54
54
|
end
|
55
55
|
|
56
56
|
def decorate?
|
57
|
-
options.fetch(:decorate
|
57
|
+
options.fetch(:decorate, true)
|
58
58
|
end
|
59
59
|
|
60
60
|
def private?
|
61
|
-
options.fetch(:private
|
61
|
+
options.fetch(:private, false)
|
62
62
|
end
|
63
63
|
|
64
64
|
def default_value
|
@@ -76,23 +76,29 @@ module Dry
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def call_proc(input, locals)
|
79
|
-
args = proc_args(input, locals)
|
80
|
-
|
81
|
-
if
|
82
|
-
proc.(
|
79
|
+
args, keywords = proc_args(input, locals)
|
80
|
+
|
81
|
+
if keywords.empty?
|
82
|
+
if proc.is_a?(Method)
|
83
|
+
proc.(*args)
|
84
|
+
else
|
85
|
+
object.instance_exec(*args, &proc)
|
86
|
+
end
|
87
|
+
elsif proc.is_a?(Method)
|
88
|
+
proc.(*args, **keywords)
|
83
89
|
else
|
84
|
-
object.instance_exec(*args, &proc)
|
90
|
+
object.instance_exec(*args, **keywords, &proc)
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
88
94
|
def proc_args(input, locals)
|
89
95
|
dependency_args = proc_dependency_args(locals)
|
90
|
-
|
96
|
+
keywords = proc_input_args(input)
|
91
97
|
|
92
|
-
if
|
93
|
-
dependency_args
|
98
|
+
if keywords.empty?
|
99
|
+
[dependency_args, {}]
|
94
100
|
else
|
95
|
-
dependency_args
|
101
|
+
[dependency_args, keywords]
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
data/lib/dry/view/exposures.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "tsort"
|
4
|
-
require "dry/equalizer"
|
4
|
+
require "dry/core/equalizer"
|
5
5
|
require "dry/view/exposure"
|
6
6
|
|
7
7
|
module Dry
|
@@ -30,7 +30,7 @@ module Dry
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def add(name, proc = nil, **options)
|
33
|
-
exposures[name] = Exposure.new(name, proc, options)
|
33
|
+
exposures[name] = Exposure.new(name, proc, **options)
|
34
34
|
end
|
35
35
|
|
36
36
|
def import(name, exposure)
|
@@ -47,7 +47,7 @@ module Dry
|
|
47
47
|
|
48
48
|
def call(input)
|
49
49
|
tsort.each_with_object({}) { |name, memo|
|
50
|
-
next unless exposure = self[name]
|
50
|
+
next unless (exposure = self[name])
|
51
51
|
|
52
52
|
value = exposure.(input, memo)
|
53
53
|
value = yield(value, exposure) if block_given?
|
@@ -56,6 +56,7 @@ module Dry
|
|
56
56
|
}.each_with_object({}) { |(name, value), memo|
|
57
57
|
memo[name] = value unless self[name].private?
|
58
58
|
}
|
59
|
+
# rubocop:enable Style/MultilineBlockChain
|
59
60
|
end
|
60
61
|
|
61
62
|
private
|
data/lib/dry/view/part.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/equalizer"
|
3
|
+
require "dry/core/equalizer"
|
4
4
|
require_relative "decorated_attributes"
|
5
5
|
require_relative "render_environment_missing"
|
6
6
|
|
@@ -70,7 +70,10 @@ module Dry
|
|
70
70
|
# @param render_env [RenderEnvironment] render environment
|
71
71
|
#
|
72
72
|
# @api public
|
73
|
-
def initialize(
|
73
|
+
def initialize(
|
74
|
+
value:, render_env: RenderEnvironmentMissing.new,
|
75
|
+
name: self.class.part_name(render_env.inflector)
|
76
|
+
)
|
74
77
|
@_name = name
|
75
78
|
@_value = value
|
76
79
|
@_render_env = render_env
|
@@ -115,7 +118,8 @@ module Dry
|
|
115
118
|
# itself responds to `#render`.
|
116
119
|
#
|
117
120
|
# @param partial_name [Symbol, String] partial name
|
118
|
-
# @param as [Symbol] the name for the Part to assume in the partial's locals.
|
121
|
+
# @param as [Symbol] the name for the Part to assume in the partial's locals. Defaults to
|
122
|
+
# the Part's `_name`.
|
119
123
|
# @param locals [Hash<Symbol, Object>] other locals to provide the partial
|
120
124
|
#
|
121
125
|
# @return [String] rendered partial
|
@@ -133,7 +137,8 @@ module Dry
|
|
133
137
|
# A convenience alias for `#_scope`. Is available unless the value
|
134
138
|
# itself responds to `#scope`.
|
135
139
|
#
|
136
|
-
# @param scope_name [Symbol, nil] scope name, used by the scope builder to determine the
|
140
|
+
# @param scope_name [Symbol, nil] scope name, used by the scope builder to determine the
|
141
|
+
# scope class
|
137
142
|
# @param locals [Hash<Symbol, Object>] other locals to provide the partial
|
138
143
|
#
|
139
144
|
# @return [Dry::View::Scope] scope
|
@@ -168,12 +173,12 @@ module Dry
|
|
168
173
|
# @param options[Hash<Symbol, Object>] other options to provide when initializing the new part
|
169
174
|
#
|
170
175
|
# @api public
|
171
|
-
def new(klass =
|
176
|
+
def new(klass = self.class, name: _name, value: _value, **options)
|
172
177
|
klass.new(
|
173
178
|
name: name,
|
174
179
|
value: value,
|
175
180
|
render_env: _render_env,
|
176
|
-
**options
|
181
|
+
**options
|
177
182
|
)
|
178
183
|
end
|
179
184
|
|
@@ -199,6 +204,7 @@ module Dry
|
|
199
204
|
super
|
200
205
|
end
|
201
206
|
end
|
207
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
202
208
|
|
203
209
|
def respond_to_missing?(name, include_private = false)
|
204
210
|
CONVENIENCE_METHODS.include?(name) || _value.respond_to?(name, include_private) || super
|