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

Custom tag compiler no longer works #4090

Closed
Chi-teck opened this issue May 13, 2024 · 9 comments
Closed

Custom tag compiler no longer works #4090

Chi-teck opened this issue May 13, 2024 · 9 comments

Comments

@Chi-teck
Copy link

Chi-teck commented May 13, 2024

I have a compiler for custom tag that is using output buffer. It worked well for years until Twig 3.9.0 was released.

Apparently there was some regression introduced in #3999.

@fabpot
Copy link
Contributor

fabpot commented May 14, 2024

The problem in your code is that you're using the ob_* functions, which is an internal implementation detail.

@nicolas-grekas
Copy link
Contributor

Unfortunately your implementation relies on output buffering, which is not used anymore internally.
You might want to consider using a CaptureNode instead since this one should be compatible with all versions of Twig.
I'm closing because there's nothing we can do here.

@ericmorand
Copy link
Contributor

@nicolas-grekas so, if using ob_* was an internal implementation detail, what was the non internal way to achieve what the OP achieved?

@nicolas-grekas
Copy link
Contributor

Using CaptureNode I suppose?

@ericmorand
Copy link
Contributor

There is no CaptureNode in Twig 3.8. So, if ob_* were internal details, how were people supposed to write capture-like nodes before 3.9?

@nicolas-grekas
Copy link
Contributor

nicolas-grekas commented May 14, 2024

Ah OK, so yes, ob_start was the way to go. Note that I'm just trying to help. Yes, we could consider some BC break here. Unfortunately, that's the kind if low-level stuff that's really hard to deal with. Twig needs to move forward and using yield makes it way better. Some extensions do need to adapt, that's true.

@chesn0k
Copy link

chesn0k commented May 14, 2024

I used SetNode Chi-teck/drupal-code-generator@89a6b47#diff-659f570da976dbf4397a186b8703135e6aad1de658e365e4dd882d8bf06336d5R36

It not be the best solution, but maybe it will be useful for someone.

BTW I think we will abandon the tag in favor of a filter

@ericmorand
Copy link
Contributor

@nicolas-grekas

Twig needs to move forward

That's why major version bump exists. There is no reason not to having pushed a new major version here.

@onlinesid
Copy link

@nicolas-grekas any handy documentation / link / example of this 'CaptureNode' thing?

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

No branches or pull requests

6 participants