Skip to content

Conversation

@23tux
Copy link
Contributor

@23tux 23tux commented Oct 29, 2025

What are you trying to accomplish?

  • When a component renders a partial, it's block is evaluated in the context of the __vc_original_view_context
  • Because of this, inside of the block you don't have access to the component's instance

What approach did you choose and why?

I used a separate #capture for the partials block, so that it get's appended into a new OutputBuffer. This output is then caputured by the __vc_original_view_context

Anything you want to highlight for special attention from reviewers?

I'm not sure about performance here, as creating a separate OutputBuffer by using #capture is an overhead.

@markokajzer
Copy link

i can confirm this closes #2443 🎉

@Spone Spone requested a review from camertron November 11, 2025 20:36
@doits
Copy link

doits commented Nov 18, 2025

👍 This probably also makes methods and variables defined attr_accessor et al available inside the block. I was just about to create an issue about this then found #2443 and this PR, glad there's a solution waiting to be merged :-)

@camertron
Copy link
Contributor

Awesome, thanks for this @23tux ❤️ I believe main's tests are passing now, could you rebase and see if we can get a clean CI run on this PR?


## main

* Capture partial block in the components context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Capture partial block in the components context
* Capture partial block in the component's context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, didn't have time. Thanks for the work!

@joelhawksley joelhawksley merged commit c67892c into ViewComponent:main Dec 3, 2025
12 of 14 checks passed
@joelhawksley
Copy link
Member

Closed by #2510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants