BladeOne
BladeOne copied to clipboard
Blade comment between switch & case statement gives error...
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.
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
It was a conversion of a Laravel project -> BladeOne and it would appear that Laravel just stripped out comments. Thanks for the config setting.
Can confirm the setting (2) works