Skip to content

Commit 349d82d

Browse files
committed
Add changelog and readme for :context support
1 parent 34f2456 commit 349d82d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
99
### Added
1010

1111
- Support for Phlex 2.0 Component context. (`HelloWorld.new.call(context: {some: :data})`).
12+
+ Like layout options, the `:context` plugin option can be used to set a default context.
13+
The value will be`dup`ed on first use.
14+
+ `#phlex_context` method to access the context.
15+
+ `#set_phlex_context` method to set the context.
1216
- `:delegate_on` plugin option to specify the object to delegate methods to.
1317
Defaults to `::Phlex::SGML` but its advised to set it to your own subclass of `::Phlex::SGML`.
1418
- `:delegate_name` plugin option to specify name of the method that delegates to the Roda app.
@@ -17,6 +21,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
1721
### Changed
1822

1923
- Update to phlex 2.0.
24+
- `#phlex_layout`, `#phlex_layout_opts`, `#phlex_layout_handler` no longer accept a value to set their value.
25+
Use their corresponding `#set_*` methods instead.
2026

2127
### Deprecated
2228

@@ -28,6 +34,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
2834

2935
### Fixed
3036

37+
- Mutating the layout options hash no longer affects subsequent requests.
38+
The value passed as `:layout_opts` plugin config is now `dup`ed on first use.
39+
Note, that mutating nested objects will still affect the original hash.
40+
3141
### Security
3242

3343
## [0.2.0] - 2024-12-13

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ gem install roda-phlex
3737
layout options, and the object to be rendered. By default, it runs
3838
`layout.new(obj, **layout_opts)`, which instantiates the layout class with the
3939
provided view object and options as keyword arguments.
40+
* `:context` (`Hash`): The context that is passed to the rendering call. (default: `{}`)
41+
To avoid external changes effecting subsequent requests, you should `.freeze` this
42+
and all nested objects.
4043
* `:delegate`: Define if or which methods should be delegated to the Roda app:
4144
+ `true` (default): Create a single `app` method that delegates to the Roda app.
4245
+ `false`: Do not create any delegate methods.

lib/roda/plugins/phlex.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module RodaPlugins
1717
# layout options, and the object to be rendered. By default, it uses the
1818
# `DEFAULT_LAYOUT_HANDLER`, which instantiates the layout class with the
1919
# provided object and options as keyword arguments.
20+
# - `:context` (+Hash+): The context that is passed to the rendering call. (default: `{}`)
2021
# - `:delegate`: Define if or which methods should be delegated to the Roda app:
2122
# + `true` (default): Create a single `app` method that delegates to the Roda app.
2223
# + `false`: Do not create any delegate methods.

0 commit comments

Comments
 (0)