You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the PHP opening or closing tags appear in a string in the template then the template is rendered incorrectly. This stems from a naive regex in the ExtractTemplate precompiler class on line 51
I think using PHP's tokenizer will fix this issue. I propose the following change to the ExtractTemplate precompiler. On first look it does indeed work, but I'd need to write some tests before submitting a pull request. Any thoughts?
/** * Extract the HTML from the given template. */protectedfunctionhtml(string$template): string
{
$tokens = PhpToken::tokenize($template);
returnimplode('', array_filter($tokens, fn (PhpToken$token) => $token->is(T_INLINE_HTML)));
}
Volt Version
1.6.1
Laravel Version
11.36,1
PHP Version
8.3.6
Database Driver & Version
No response
Description
If the PHP opening or closing tags appear in a string in the template then the template is rendered incorrectly. This stems from a naive regex in the
ExtractTemplate
precompiler class on line 51volt/src/Precompilers/ExtractTemplate.php
Line 51 in 39e225e
Steps To Reproduce
The following simple Volt component demonstrates the issue.
There is nothing special in the layout component
This gives the following output (note the extract of PHP code that has been rendered as part of the template)
The text was updated successfully, but these errors were encountered: