Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate #content to be a slot #1974

Open
BlakeWilliams opened this issue Jan 12, 2024 · 0 comments
Open

Migrate #content to be a slot #1974

BlakeWilliams opened this issue Jan 12, 2024 · 0 comments
Labels

Comments

@BlakeWilliams
Copy link
Contributor

This could be a breaking change, but we'd want to include a way of opting into the legacy behavior for at least 1 version to make the migration easier.

I propose that we:

  1. Implement content_is_a_slot! method to allow components in this version of ViewComponent to opt-in to the new behavior as well as break inheritance of the method mentioned below once we release 4.0.
  2. Implement a legacy_content_behavior! (or better named) method that can be called in components (and inherited) to opt-in to the current behavior. This would be a noop until 4.0.
  3. Now in 4.0 or when content_is_a_slot! is declared, when components are passed a block the resulting HTML and string values are not passed as #content and the block is always evaluated (unlike today). To pass content, c.content do will need to be called in the block or via the change mentioned below.
  4. Update with_content to support being passed a block, so existing components that rely on the default content behavior (without calling slots) can migrate via render(MyComponent.new) { "hi!" } -> render(MyComponent.new).with_content { "hi" }.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant