rex()
function is the shortest form of fetching
the direct string of a Compiler object rendered component. In this case,
components are rendered with the Compiler object and the relative rendered
string is returned.
The boy is {{ $age }} years today
rex()
function as shown below:
<?php
namespace spoova/mi/windows/Routes/Home;
use window;
class Home extends Window {
function __construct() {
//fetch template string
$templateString = rex('home', fn() => compile(['age' => 13]));
var_dump( $templateString );
}
}
compile()
function unless an argument is needed to be parsed.
We can also directly display the rendered components as shown below:
<?php
namespace spoova/mi/windows/Routes;
use window;
class Home extends Window {
function __construct() {
//render template string
echo rex('home', fn() => compile(['age' => 13]) );
}
}
rex()
method that directly returns the string
of a compiled component. So, rather than use the approach above, we can address this similary using
a better approach below :
<?php
namespace spoova/mi/windows/Routes;
use window;
class Home extends Window {
function __construct() {
//fetch template string
$string = compile('home', ['age' => 13])->rex();
var_dump($string);
}
}