@@ -70,11 +70,9 @@ pub fn preprocess(content: &str) -> (String, BladeSourceMap) {
7070 let remaining = & line_chars[ char_idx..] ;
7171 let rest_str: String = remaining. iter ( ) . collect ( ) ;
7272 if rest_str. starts_with ( "@endverbatim" ) {
73- // End verbatim: close comment, skip the directive, return to Html
7473 let directive_len = "@endverbatim" . len ( ) ;
7574 char_idx += directive_len;
7675 current_utf16_col += directive_len as u32 ;
77- processed. push_str ( " */ " ) ;
7876 mode = Mode :: Html ;
7977 } else {
8078 // Skip char (it's inside the comment)
@@ -122,7 +120,7 @@ pub fn preprocess(content: &str) -> (String, BladeSourceMap) {
122120 replacement = "" . to_string ( ) ;
123121 next_mode = Mode :: Html ;
124122 } else if directive == "verbatim" {
125- replacement = " /* " . to_string ( ) ;
123+ replacement = "" . to_string ( ) ;
126124 next_mode = Mode :: Verbatim ;
127125 } else if directive == "empty" {
128126 // @empty with parens = if(empty(...)):, without parens = forelse separator
@@ -532,15 +530,21 @@ mod tests {
532530 fn test_preprocess_verbatim ( ) {
533531 let content = "@verbatim\n {{ $name }}\n @if(true)\n @endverbatim\n <p>{{ $real }}</p>\n " ;
534532 let ( php, _) = preprocess ( content) ;
535- // Content between @verbatim and @endverbatim should be commented out
536- assert ! ( php. contains( "/*" ) , "should open comment: {}" , php) ;
537- assert ! ( php. contains( "*/" ) , "should close comment: {}" , php) ;
538533 // The {{ $name }} inside verbatim should NOT produce echo
539- assert ! ( !php. contains( "$name" ) , "verbatim content should be commented out : {}" , php) ;
534+ assert ! ( !php. contains( "$name" ) , "verbatim content should be skipped : {}" , php) ;
540535 // The {{ $real }} after @endverbatim should work normally
541536 assert ! ( php. contains( "$real" ) , "content after endverbatim should work: {}" , php) ;
542537 }
543538
539+ #[ test]
540+ fn test_preprocess_verbatim_with_comment_syntax ( ) {
541+ // Verbatim blocks may contain */ which would break PHP block comments
542+ let content = "@verbatim\n {{ /* js comment */ value }}\n @endverbatim\n <p>{{ $after }}</p>\n " ;
543+ let ( php, _) = preprocess ( content) ;
544+ assert ! ( !php. contains( "js comment" ) , "verbatim content should be skipped: {}" , php) ;
545+ assert ! ( php. contains( "$after" ) , "content after endverbatim should work: {}" , php) ;
546+ }
547+
544548 #[ test]
545549 fn test_preprocess_error_directive ( ) {
546550 let content = "@error('email')\n <p>{{ $message }}</p>\n @enderror\n " ;
0 commit comments