Fix PHP tags in strings breaking Volt template rendering - #158
Closed
calebporzio wants to merge 1 commit into
Closed
calebporzio wants to merge 1 commit into
calebporzio wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Literal
<?phpor?>text in Volt state can break a valid component's rendering. For example, a component with one root and a title containing?>currently raisesMultipleRootElementsDetectedExceptionon Livewire 4 because template extraction mistakes the string for the end of its PHP block.Use PHP tokens to identify real PHP boundaries. Preserve the newline included in closing-tag tokens and leave short echo tags intact. Add regression coverage for the reported strings, comments/multiline strings, short echo tags, and rendering through a Livewire update.
Fixes #126. This follows the reporter's suggestion to use PHP's tokenizer.
Verified the failure before the fix on Volt 1.11.2 / Livewire 4.4.5 / Laravel 13.31.0. In a real Chrome browser, the same page now returns 200, displays the literal text correctly, and updates successfully without JavaScript exceptions.
Validation: all 96 unit tests pass, the new functional regression passes, PHPStan reports no errors, and Pint /
git diff --checkpass.