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

Blade comment between switch & case statement gives error... #194

Open
AzzaAzza69 opened this issue Oct 8, 2024 · 2 comments
Open

Blade comment between switch & case statement gives error... #194

AzzaAzza69 opened this issue Oct 8, 2024 · 2 comments

Comments

@AzzaAzza69
Copy link

eg.

@switch($expr)
  {{-- test comment --}}
  @case('value')

renders to:

<?php switch ($expr) {
 <?php /* test comment */ ?>
 case ('value'): ?>

which gives "syntax error, unexpected '<', expecting case (T_CASE) or default (T_DEFAULT) or '}'" for the middle line.

@jorgecc
Copy link
Member

jorgecc commented Oct 8, 2024

Technically, it is a problem with the PHP parser.
It is impossible to deal with this problem without impacting the performance. And since comments aren't so vital, so I added a new field to determine how to work with the comments.

$blade=new BladeOne(null,null,0,2);  // the last 2 means:
// 0: means comments are converted into PHP code.
// 1: means comments are converted into HTML comments <-- some comment -->
// 2: means that comments are ignored, so it won't crash "try/case" blocks

https://github.com/EFTEC/BladeOne/releases/tag/4.14

@AzzaAzza69
Copy link
Author

It was a conversion of a Laravel project -> BladeOne and it would appear that Laravel just stripped out comments.
Thanks for the config setting.

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

No branches or pull requests

2 participants