hanami-view 3.0.0.rc1 → 3.0.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 +32 -3
- data/lib/hanami/view/context.rb +1 -1
- data/lib/hanami/view/rendering.rb +0 -6
- data/lib/hanami/view/scope.rb +1 -1
- data/lib/hanami/view/tilt.rb +14 -4
- data/lib/hanami/view/version.rb +1 -1
- data/lib/hanami/view.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3551aaf55b76ccc3396f09f954804be884cad50f774f8ae68b980799d9699de4
|
|
4
|
+
data.tar.gz: '08012b7065f9b8015cf2f274d595b7d6f6830c8071d23285ba268bc7ca7e99b7'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb475608c10965166e12c6477793e6b47241f7888b4800f84b3e10075ae6f6a3d14494df18c607e0ce6f8514be450c201eaea5f4cb46203d6fea8af1e5073315
|
|
7
|
+
data.tar.gz: 11f2b19132241ce7ce76c928ef5be1f4a11dc849411b20d90197fa7c7168c3c2068da219d63150a6bac21d64244b6edd167eeced1442315eeaa7db8be07c335f
|
data/CHANGELOG.md
CHANGED
|
@@ -19,7 +19,34 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
|
|
|
19
19
|
|
|
20
20
|
### Security
|
|
21
21
|
|
|
22
|
-
[Unreleased]: https://github.com/hanami/view/compare/v3.0.0
|
|
22
|
+
[Unreleased]: https://github.com/hanami/view/compare/v3.0.0...HEAD
|
|
23
|
+
|
|
24
|
+
## [3.0.0] - 2026-06-30
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Track the currently-rendering template name. (@timriley in #277)
|
|
29
|
+
|
|
30
|
+
Expose this as `Hanami::View::Scope#_template_name` (with `template_name` as a convenience alias) and `Hanami::View::Context#current_template_name`.
|
|
31
|
+
|
|
32
|
+
The name is resolved path of the file actually being rendered, relative to its configured `paths` directory, with format/engine extensions stripped. For example, `render("form")` from inside `posts/show.html.erb` returns `"posts/_form"`; a layout at `layouts/app.html.erb` returns `"layouts/app"`.
|
|
33
|
+
|
|
34
|
+
The current template name can be used to enable such behaviors as lazy/relative key lookups for i18n view helpers.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- **BREAKING:** Default to undecorated exposures. (@timriley in #274)
|
|
39
|
+
|
|
40
|
+
Decorate your exposures with the new `.decorate` method, or the `decorate: true` option for `.expose`. Default back to decorated exposures via `config.decorate_exposures = true`.
|
|
41
|
+
- Cache the view's resolved configuration as a frozen `Data` snapshot (via dry-configurable's `#to_data`) at initialization, avoiding repeated config lookups on the rendering hot path for improved memory usage and speed. (@cllns in #276)
|
|
42
|
+
- Require Ruby 3.3 or newer.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- Allow the gem to be eager loaded by Zeitwerk when the optional haml and slim gems are not installed. (@timriley in #279)
|
|
47
|
+
- Use our own Haml template engine even when the haml gem is required before hanami-view. (@timriley in #279)
|
|
48
|
+
|
|
49
|
+
[3.0.0]: https://github.com/hanami/view/compare/v2.3.1...v3.0.0
|
|
23
50
|
|
|
24
51
|
## [3.0.0.rc1] - 2026-06-16
|
|
25
52
|
|
|
@@ -27,9 +54,11 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
|
|
|
27
54
|
|
|
28
55
|
- Track the currently-rendering template name. (@timriley in #277)
|
|
29
56
|
|
|
30
|
-
Expose
|
|
57
|
+
Expose this as `Hanami::View::Scope#_template_name` (with `template_name` as a convenience alias) and `Hanami::View::Context#current_template_name`.
|
|
58
|
+
|
|
59
|
+
The name is resolved path of the file actually being rendered, relative to its configured `paths` directory, with format/engine extensions stripped. For example, `render("form")` from inside `posts/show.html.erb` returns `"posts/_form"`; a layout at `layouts/app.html.erb` returns `"layouts/app"`.
|
|
31
60
|
|
|
32
|
-
|
|
61
|
+
The current template name can be used to enable such behaviors as lazy/relative key lookups for i18n view helpers.
|
|
33
62
|
|
|
34
63
|
### Changed
|
|
35
64
|
|
data/lib/hanami/view/context.rb
CHANGED
|
@@ -37,9 +37,6 @@ module Hanami
|
|
|
37
37
|
# no render is in progress.
|
|
38
38
|
#
|
|
39
39
|
# @return [String, nil]
|
|
40
|
-
#
|
|
41
|
-
# @api public
|
|
42
|
-
# @since x.x.x
|
|
43
40
|
def current_template_name
|
|
44
41
|
renderer.current_template_name
|
|
45
42
|
end
|
|
@@ -48,9 +45,6 @@ module Hanami
|
|
|
48
45
|
# rendered.
|
|
49
46
|
#
|
|
50
47
|
# @return [Array<String>]
|
|
51
|
-
#
|
|
52
|
-
# @api private
|
|
53
|
-
# @since x.x.x
|
|
54
48
|
def current_template_names
|
|
55
49
|
renderer.current_template_names
|
|
56
50
|
end
|
data/lib/hanami/view/scope.rb
CHANGED
data/lib/hanami/view/tilt.rb
CHANGED
|
@@ -10,14 +10,24 @@ module Hanami
|
|
|
10
10
|
# @api private
|
|
11
11
|
# @since 2.1.0
|
|
12
12
|
Mapping = ::Tilt.default_mapping.dup.tap { |mapping|
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
|
|
13
|
+
# Unregister any existing mappings for the extensions we provide our own engines for.
|
|
14
|
+
#
|
|
15
|
+
# Tilt preferences non-lazy registrations over lazy ones (see `Tilt::Mapping#lookup`). So if
|
|
16
|
+
# "haml" or "slim" has been required before this mapping is built (each of which registers
|
|
17
|
+
# its own non-lazy mapping with Tilt), our own lazy-registered adapters below would be
|
|
18
|
+
# shadowed and never picked up, and templates would render without our specific required
|
|
19
|
+
# behavior.
|
|
20
|
+
#
|
|
21
|
+
# Unregistering first ensures our engines are always used, regardless of load order.
|
|
22
|
+
mapping.unregister "erb", "rhtml", "haml", "slim"
|
|
16
23
|
|
|
17
24
|
# Register our own ERB template.
|
|
18
25
|
mapping.register_lazy "Hanami::View::ERB::Template", "hanami/view/erb/template", "erb", "rhtml"
|
|
19
26
|
|
|
20
|
-
# Register
|
|
27
|
+
# Register templates for Haml and Slim that set the `use_html_safe: true` option.
|
|
28
|
+
#
|
|
29
|
+
# We register these lazily so that the optional "haml" and "slim" gems only need to be
|
|
30
|
+
# installed when their templates are actually used.
|
|
21
31
|
#
|
|
22
32
|
# Our template namespaces below have the "Adapter" suffix to work around a bug in Tilt's
|
|
23
33
|
# `Mapping#const_defined?`, which (if slim was already required) would receive
|
data/lib/hanami/view/version.rb
CHANGED
data/lib/hanami/view.rb
CHANGED
|
@@ -30,7 +30,12 @@ module Hanami
|
|
|
30
30
|
loader.ignore(
|
|
31
31
|
"#{root}/hanami-view.rb",
|
|
32
32
|
"#{root}/hanami/view/version.rb",
|
|
33
|
-
"#{root}/hanami/view/errors.rb"
|
|
33
|
+
"#{root}/hanami/view/errors.rb",
|
|
34
|
+
# These adapters require the optional "haml" and "slim" gems. They are loaded lazily by
|
|
35
|
+
# Tilt (see Hanami::View::Tilt) only when their respective template engines are used;
|
|
36
|
+
# ignore them here to allow eager loading without those gems installed.
|
|
37
|
+
"#{root}/hanami/view/tilt/haml_adapter.rb",
|
|
38
|
+
"#{root}/hanami/view/tilt/slim_adapter.rb"
|
|
34
39
|
)
|
|
35
40
|
loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami-view.rb")
|
|
36
41
|
loader.inflector.inflect(
|
|
@@ -246,7 +251,7 @@ module Hanami
|
|
|
246
251
|
#
|
|
247
252
|
# @param value [Boolean] whether to decorate exposures by default
|
|
248
253
|
# @api public
|
|
249
|
-
# @since
|
|
254
|
+
# @since 3.0.0
|
|
250
255
|
# @!scope class
|
|
251
256
|
setting :decorate_exposures, default: false
|
|
252
257
|
|