view()
function renders template file in a slightly different way and does not return
the compiler object because files are sliced directly using a template slicer tool which returns a
string of rendered components. Template files in this case are rendered directly
with parsed arguments and the resultant template string is returned. In most cases, the returned string have
to be subjected to further processing which is why the template string returned may most likely be dependent
on the window self::load()
method.
The boy is <?= $age ?> years today
"$age"
value to the template file and have it loaded through the view()
function as shown below:
<?php namespace spoova/mi/windows/Routes/Home; use window; class Home extends Window { function __construct() { //fetch template string $templateString = view('home', ['age' => 13]); // The boy is 13 years today self::load( 'home', fn() => $templateString ); } }
view()
function, they are usually saved
temporarily for immediate use. In a short and close cycle, this can become an advantage
for placeholders. Hence, a template file of the format below may still work.
The boy is {{ $age }} years today
<?php namespace spoova/mi/windows/Routes/Home; use window; class Home extends Window { function __construct() { //fetch template string $templateString = view('home', ['age' => 13]); // The boy is 13 years today self::load( 'home', fn() => $templateString ); } }
compile()
and rex()
functions.