Corviz / crow

Yet another template engine for PHP
https://corviz.github.io/crow/
MIT License
6 stars 2 forks source link

Error: @php directive does not work as expected in an assumed scenario #9

Open nael94 opened 3 months ago

nael94 commented 3 months ago

Here is a quick example to describe the error:

@extends ('layout/main')

@php
  // This is php code
  $from = 10;
  $to = $from + 10;
@endphp

@section('body')
  {{ $to }}
@endsection

It is assumed to prepare the variable $to to be usable in the current viewfile, but it returns this error: Deprecated: htmlentities(): Passing null to parameter 1 ($string) of type string is deprecated in C:\xampp\htdocs\crow\vendor\corviz\crow\src\Crow.php(138) : eval()'d code on line 1

nael94 commented 3 months ago

Okay I tried to move the @php block to inside the @section block and it works. I prefer to introduce a way to share all codes from @php block through all that view file for a better code logic organizing.