@@ -454,7 +454,7 @@ public function code($code)
454
454
}
455
455
456
456
/** This method gets the contents of the given file. If $raw == true then it will return the raw HTML code */
457
- public function loadFile ($ filePath = false , $ raw = false )
457
+ public function loadFile ($ filePath = false , $ raw = false , $ var = false )
458
458
{
459
459
if ($ filePath ) {
460
460
$ filePath = preg_replace ("/\/{1,}| \\{1,}/ " , DIRECTORY_SEPARATOR , $ filePath );
@@ -464,8 +464,8 @@ public function loadFile($filePath = false, $raw = false)
464
464
}
465
465
$ path = $ instance ->templateDir . $ filePath ;
466
466
if (file_exists ($ path )) {
467
- $ instance -> HTML = file_get_contents ($ path );
468
- if (preg_match_all ($ this ->templateIncludeRegex , $ instance -> HTML , $ matches )) {
467
+ $ HTML = file_get_contents ($ path );
468
+ if (preg_match_all ($ this ->templateIncludeRegex , $ HTML , $ matches )) {
469
469
$ matches = $ matches [1 ];
470
470
$ class = get_class ($ instance );
471
471
foreach ($ matches as $ match ) {
@@ -479,10 +479,17 @@ public function loadFile($filePath = false, $raw = false)
479
479
unset($ data );
480
480
$ fileName = explode (DIRECTORY_SEPARATOR , $ fileName );
481
481
$ fileName = $ fileName [count ($ fileName ) - 1 ];
482
- $ instance -> HTML = preg_replace ("/\<\_template\:loadFile\(.*? " . addslashes ($ fileName ) . "\)( )?(\/)?\/>/ " , $ childNode ->rawRender (), $ instance -> HTML );
482
+ $ HTML = preg_replace ("/\<\_template\:loadFile\(.*? " . addslashes ($ fileName ) . "\)( )?(\/)?\/>/ " , $ childNode ->rawRender (), $ HTML );
483
483
unset($ childNode , $ aux , $ fileName );
484
484
}
485
485
}
486
+ if ($ var ) {
487
+ $ instance ->setVar ([$ var => $ HTML ]);
488
+ $ instance ->prepareDocument ();
489
+ } else {
490
+ $ instance ->HTML = $ HTML ;
491
+ }
492
+ unset($ HTML );
486
493
if ($ raw ) {
487
494
return $ instance ->rawRender ();
488
495
}
0 commit comments