hanami-view 2.0.0.alpha2 → 2.0.0.alpha3
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 +6 -1
- data/README.md +42 -18
- data/hanami-view.gemspec +2 -2
- data/lib/hanami/view/application_configuration.rb +1 -1
- data/lib/hanami/view/errors.rb +15 -0
- data/lib/hanami/view/standalone_view.rb +8 -4
- data/lib/hanami/view/version.rb +1 -1
- data/lib/hanami/view.rb +11 -11
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b6dc01adb32ad3baabc7a15012119e8814de8ec999c4b5da2009204c3b047c
|
4
|
+
data.tar.gz: 8ef681f6101b085dec6e03f6de0815dfa55d8cbd91e960bf0144e4a46da5cce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5704c147558d2a0e3e86d59f3b665ee65265a9398584b1d3478970551d9a022551ea04420444622c2c4967ab3406d29ea9dab7c13462207364ea985aa4af723
|
7
|
+
data.tar.gz: 5909511de76e1daf91a375c5947103040c2ec40208ea52882771204249cc2d4aef23d2ceaa8dac24cc960dbba978f3e4c6c08fac52118673b9c22580571f10fb
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# Hanami::View
|
2
2
|
View layer for Hanami
|
3
3
|
|
4
|
-
## v2.0.0.
|
4
|
+
## v2.0.0.alpha3 - 2021-11-09
|
5
|
+
### Added
|
6
|
+
- [Pablo Vicente] Raise `LayoutNotFoundError` exception with friendlier, more specific error message when layouts cannot be found
|
5
7
|
|
6
8
|
### Changed
|
9
|
+
- [Tim Riley] (Internal) Updated settings to use updated dry-configurable `setting` 0.13.0 API
|
7
10
|
|
11
|
+
## v2.0.0.alpha2 - 2021-05-04
|
12
|
+
### Changed
|
8
13
|
- [Tim Riley] Replaced entire gem with dry-view (now renamed to hanami-view). See [dry-view's documentation](https://dry-rb.org/gems/dry-view/) for its capabilities and [the dry-view changelog](CHANGELOG.dry-view.md) for its history.
|
9
14
|
|
10
15
|
## v1.3.1 - 2019-01-18
|
data/README.md
CHANGED
@@ -1,28 +1,52 @@
|
|
1
|
-
|
2
|
-
[actions]: https://github.com/hanami/view/actions
|
3
|
-
[codacy]: https://www.codacy.com/gh/hanami/view
|
4
|
-
[chat]: https://dry-rb.zulipchat.com
|
5
|
-
[inchpages]: http://inch-ci.org/github/hanami/view
|
1
|
+
# Hanami::View
|
6
2
|
|
7
|
-
|
3
|
+
A view layer for [Hanami](http://hanamirb.org)
|
8
4
|
|
9
|
-
|
10
|
-
[][actions]
|
11
|
-
[][codacy]
|
12
|
-
[][codacy]
|
13
|
-
[][inchpages]
|
5
|
+
## Version
|
14
6
|
|
15
|
-
|
7
|
+
**This branch contains the code for `hanami-view` 2.x.**
|
16
8
|
|
17
|
-
|
18
|
-
* [API documentation](http://rubydoc.info/gems/hanami-view)
|
9
|
+
## Status
|
19
10
|
|
20
|
-
|
11
|
+
[](https://badge.fury.io/rb/hanami-view)
|
12
|
+
[](https://github.com/hanami/view/actions?query=workflow%3Aci+branch%3Amain)
|
13
|
+
[](https://codecov.io/gh/hanami/view)
|
14
|
+
[](https://depfu.com/github/hanami/view?project=Bundler)
|
15
|
+
[](http://inch-ci.org/github/hanami/view)
|
21
16
|
|
22
|
-
|
17
|
+
## Contact
|
23
18
|
|
24
|
-
*
|
25
|
-
*
|
19
|
+
* Home page: http://hanamirb.org
|
20
|
+
* Community: http://hanamirb.org/community
|
21
|
+
* Guides: https://guides.hanamirb.org
|
22
|
+
* Mailing List: http://hanamirb.org/mailing-list
|
23
|
+
* API Doc: http://rdoc.info/gems/hanami-view
|
24
|
+
* Bugs/Issues: https://github.com/hanami/view/issues
|
25
|
+
* Chat: http://chat.hanamirb.org
|
26
|
+
|
27
|
+
## Rubies
|
28
|
+
|
29
|
+
__Hanami::view__ supports Ruby (MRI) 2.6+
|
30
|
+
|
31
|
+
## Installation
|
32
|
+
|
33
|
+
Add this line to your application's Gemfile:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem "hanami/view"
|
37
|
+
```
|
38
|
+
|
39
|
+
And then execute:
|
40
|
+
|
41
|
+
```shell
|
42
|
+
$ bundle
|
43
|
+
```
|
44
|
+
|
45
|
+
Or install it yourself as:
|
46
|
+
|
47
|
+
```shell
|
48
|
+
$ gem install hanami-view
|
49
|
+
```
|
26
50
|
|
27
51
|
## License
|
28
52
|
|
data/hanami-view.gemspec
CHANGED
@@ -20,14 +20,14 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
23
|
-
spec.metadata['changelog_uri'] = 'https://github.com/hanami/view/blob/
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/hanami/view/blob/main/CHANGELOG.md'
|
24
24
|
spec.metadata['source_code_uri'] = 'https://github.com/hanami/view'
|
25
25
|
spec.metadata['bug_tracker_uri'] = 'https://github.com/hanami/view/issues'
|
26
26
|
|
27
27
|
spec.required_ruby_version = ">= 2.4.0"
|
28
28
|
|
29
29
|
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
|
30
|
-
spec.add_runtime_dependency "dry-configurable", "~> 0.
|
30
|
+
spec.add_runtime_dependency "dry-configurable", "~> 0.13", ">= 0.13.0"
|
31
31
|
spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
|
32
32
|
spec.add_runtime_dependency "dry-inflector", "~> 0.1"
|
33
33
|
spec.add_runtime_dependency "tilt", "~> 2.0", ">= 2.0.6"
|
data/lib/hanami/view/errors.rb
CHANGED
@@ -25,5 +25,20 @@ module Hanami
|
|
25
25
|
super(msg)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
# Error raised when layout could not be found within a view's configured
|
30
|
+
# paths
|
31
|
+
#
|
32
|
+
# @api private
|
33
|
+
class LayoutNotFoundError < StandardError
|
34
|
+
def initialize(layout_name, lookup_paths)
|
35
|
+
msg = [
|
36
|
+
"Layout +#{layout_name}+ could not be found in paths:",
|
37
|
+
lookup_paths.map { |path| " - #{path}" }
|
38
|
+
].join("\n\n")
|
39
|
+
|
40
|
+
super(msg)
|
41
|
+
end
|
42
|
+
end
|
28
43
|
end
|
29
44
|
end
|
@@ -351,10 +351,14 @@ module Hanami
|
|
351
351
|
|
352
352
|
if layout?
|
353
353
|
layout_env = self.class.layout_env(format: format, context: context)
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
354
|
+
begin
|
355
|
+
output = env.template(
|
356
|
+
self.class.layout_path,
|
357
|
+
layout_env.scope(config.scope, layout_locals(locals))
|
358
|
+
) { output }
|
359
|
+
rescue TemplateNotFoundError
|
360
|
+
raise LayoutNotFoundError.new(config.layout, config.paths)
|
361
|
+
end
|
358
362
|
end
|
359
363
|
|
360
364
|
Rendered.new(output: output, locals: locals)
|
data/lib/hanami/view/version.rb
CHANGED
data/lib/hanami/view.rb
CHANGED
@@ -56,9 +56,9 @@ module Hanami
|
|
56
56
|
#
|
57
57
|
# @api public
|
58
58
|
# @!scope class
|
59
|
-
setting :paths
|
59
|
+
setting :paths, constructor: -> paths {
|
60
60
|
Array(paths).map { |path| Path[path] }
|
61
|
-
|
61
|
+
}
|
62
62
|
|
63
63
|
# @overload config.template=(name)
|
64
64
|
# Set the name of the template for rendering this view. Template name
|
@@ -96,7 +96,7 @@ module Hanami
|
|
96
96
|
# @param name [String, FalseClass, nil] layout name, or false to indicate no layout
|
97
97
|
# @api public
|
98
98
|
# @!scope class
|
99
|
-
setting :layout, false
|
99
|
+
setting :layout, default: false
|
100
100
|
|
101
101
|
# @overload config.layouts_dir=(dir)
|
102
102
|
# Set the name of the directory (within the configured `paths`) holding
|
@@ -105,7 +105,7 @@ module Hanami
|
|
105
105
|
# @param dir [String] directory name
|
106
106
|
# @api public
|
107
107
|
# @!scope class
|
108
|
-
setting :layouts_dir, "layouts"
|
108
|
+
setting :layouts_dir, default: "layouts"
|
109
109
|
|
110
110
|
# @overload config.scope=(scope_class)
|
111
111
|
# Set the scope class to use when rendering the view's template.
|
@@ -131,7 +131,7 @@ module Hanami
|
|
131
131
|
# @param context [Hanami::View::Context] context object
|
132
132
|
# @api public
|
133
133
|
# @!scope class
|
134
|
-
setting :default_context, Context.new.freeze
|
134
|
+
setting :default_context, default: Context.new.freeze
|
135
135
|
|
136
136
|
# @overload config.default_format=(format)
|
137
137
|
# Set the default format to use when rendering.
|
@@ -141,7 +141,7 @@ module Hanami
|
|
141
141
|
# @param format [Symbol]
|
142
142
|
# @api public
|
143
143
|
# @!scope class
|
144
|
-
setting :default_format, :html
|
144
|
+
setting :default_format, default: :html
|
145
145
|
|
146
146
|
# @overload config.scope_namespace=(namespace)
|
147
147
|
# Set a namespace that will be searched when building scope classes.
|
@@ -162,7 +162,7 @@ module Hanami
|
|
162
162
|
# @param part_builder [Class]
|
163
163
|
# @api public
|
164
164
|
# @!scope class
|
165
|
-
setting :part_builder, PartBuilder
|
165
|
+
setting :part_builder, default: PartBuilder
|
166
166
|
|
167
167
|
# @overload config.scope_namespace=(namespace)
|
168
168
|
# Set a namespace that will be searched when building scope classes.
|
@@ -183,7 +183,7 @@ module Hanami
|
|
183
183
|
# @param scope_builder [Class]
|
184
184
|
# @api public
|
185
185
|
# @!scope class
|
186
|
-
setting :scope_builder, ScopeBuilder
|
186
|
+
setting :scope_builder, default: ScopeBuilder
|
187
187
|
|
188
188
|
# @overload config.inflector=(inflector)
|
189
189
|
# Set an inflector to provide to the part_builder and scope_builder.
|
@@ -193,7 +193,7 @@ module Hanami
|
|
193
193
|
# @param inflector
|
194
194
|
# @api public
|
195
195
|
# @!scope class
|
196
|
-
setting :inflector, Dry::Inflector.new
|
196
|
+
setting :inflector, default: Dry::Inflector.new
|
197
197
|
|
198
198
|
# @overload config.renderer_options=(options)
|
199
199
|
# A hash of options to pass to the template engine. Template engines are
|
@@ -208,9 +208,9 @@ module Hanami
|
|
208
208
|
# @param options [Hash] renderer options
|
209
209
|
# @api public
|
210
210
|
# @!scope class
|
211
|
-
setting :renderer_options, DEFAULT_RENDERER_OPTIONS
|
211
|
+
setting :renderer_options, default: DEFAULT_RENDERER_OPTIONS, constructor: -> options {
|
212
212
|
DEFAULT_RENDERER_OPTIONS.merge(options.to_h).freeze
|
213
|
-
|
213
|
+
}
|
214
214
|
|
215
215
|
# @overload config.renderer_engine_mapping=(mapping)
|
216
216
|
# A hash specifying the (Tilt-compatible) template engine class to use
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Riley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -31,14 +31,20 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '0.
|
34
|
+
version: '0.13'
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.13.0
|
35
38
|
type: :runtime
|
36
39
|
prerelease: false
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
42
|
- - "~>"
|
40
43
|
- !ruby/object:Gem::Version
|
41
|
-
version: '0.
|
44
|
+
version: '0.13'
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.13.0
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: dry-core
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +185,7 @@ licenses:
|
|
179
185
|
- MIT
|
180
186
|
metadata:
|
181
187
|
allowed_push_host: https://rubygems.org
|
182
|
-
changelog_uri: https://github.com/hanami/view/blob/
|
188
|
+
changelog_uri: https://github.com/hanami/view/blob/main/CHANGELOG.md
|
183
189
|
source_code_uri: https://github.com/hanami/view
|
184
190
|
bug_tracker_uri: https://github.com/hanami/view/issues
|
185
191
|
post_install_message:
|
@@ -197,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
203
|
- !ruby/object:Gem::Version
|
198
204
|
version: 1.3.1
|
199
205
|
requirements: []
|
200
|
-
rubygems_version: 3.2.
|
206
|
+
rubygems_version: 3.2.3
|
201
207
|
signing_key:
|
202
208
|
specification_version: 4
|
203
209
|
summary: A complete, standalone view rendering system that gives you everything you
|