Description
Currently, Webrium View supports inline PHP execution using the @php( $a = 'b' ) syntax. While this works great for single-line expressions or variable assignments, it becomes hard to read and maintain when dealing with complex, multiline logic or defining multiple temporary variables.
To improve readability and developer flexibility, we should extend the current compiler to support multiline native PHP blocks using the @php and @endphp syntax, while maintaining backward compatibility with the existing inline syntax.
Current Syntax (Supported)
Proposed Syntax (To Be Added)
@php
$counter = 1;
$status = 'active';
$role = 'admin';
@endphp
Expected Behavior
The compiler should be able to distinguish between the two formats:
-
If @php is followed by an opening parenthesis (, handle it as the current inline execution.
-
If @php is followed by a newline/whitespace, treat everything until @endphp as a raw PHP block and compile it into .
Checklist
Description
Currently, Webrium View supports inline PHP execution using the
@php( $a = 'b' )syntax. While this works great for single-line expressions or variable assignments, it becomes hard to read and maintain when dealing with complex, multiline logic or defining multiple temporary variables.To improve readability and developer flexibility, we should extend the current compiler to support multiline native PHP blocks using the
@phpand@endphpsyntax, while maintaining backward compatibility with the existing inline syntax.Current Syntax (Supported)
Proposed Syntax (To Be Added)
Expected Behavior
The compiler should be able to distinguish between the two formats:
If @php is followed by an opening parenthesis (, handle it as the current inline execution.
If @php is followed by a newline/whitespace, treat everything until @endphp as a raw PHP block and compile it into .
Checklist