Fixed issue with rendering a template within a section
This commit is contained in:
23
Template.php
23
Template.php
@@ -39,9 +39,9 @@ class Template
|
|||||||
|
|
||||||
private $sections = array();
|
private $sections = array();
|
||||||
private $currentSection = false;
|
private $currentSection = false;
|
||||||
private $master = false;
|
|
||||||
|
|
||||||
private function __construct() {
|
private function __construct() {
|
||||||
|
$this->context[0]['master'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function GetCompiledFilename($tFile) {
|
private function GetCompiledFilename($tFile) {
|
||||||
@@ -87,8 +87,6 @@ class Template
|
|||||||
|
|
||||||
extract($this->context[$this->level], EXTR_REFS | EXTR_SKIP);
|
extract($this->context[$this->level], EXTR_REFS | EXTR_SKIP);
|
||||||
|
|
||||||
$this->master = false;
|
|
||||||
|
|
||||||
$compiledTemplate = $this->GetCompiled($tFile);
|
$compiledTemplate = $this->GetCompiled($tFile);
|
||||||
if ($compiledTemplate == false) {
|
if ($compiledTemplate == false) {
|
||||||
$templateContents = file_get_contents($tFile);
|
$templateContents = file_get_contents($tFile);
|
||||||
@@ -97,19 +95,21 @@ class Template
|
|||||||
array('<?php echo $this->$1 ;?>', '<?php echo $1 ;?>', '<?php $this->$1 ;?>', '<?php $1 ;?>'),
|
array('<?php echo $this->$1 ;?>', '<?php echo $1 ;?>', '<?php $this->$1 ;?>', '<?php $1 ;?>'),
|
||||||
$templateContents);
|
$templateContents);
|
||||||
$this->SaveCompiled($tFile, $templateContents);
|
$this->SaveCompiled($tFile, $templateContents);
|
||||||
$result = eval('?>'.$templateContents);
|
ob_start();
|
||||||
|
eval('?>'.$templateContents);
|
||||||
|
$result = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
} else {
|
} else {
|
||||||
ob_start();
|
ob_start();
|
||||||
include($compiledTemplate);
|
include($compiledTemplate);
|
||||||
$result = ob_get_clean();
|
$result = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$currentTemplater = false;
|
self::$currentTemplater = false;
|
||||||
if ($this->currentSection != False)
|
|
||||||
$this->EndSection();
|
|
||||||
|
|
||||||
if ($this->master != false) {
|
if ($this->context[0]['master'] != false && $this->level == 1) {
|
||||||
return $this->Render($this->master);
|
return $this->Render($this->context[0]['master']);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->context[$this->level]);
|
unset($this->context[$this->level]);
|
||||||
@@ -119,14 +119,15 @@ class Template
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function SetMaster($file) {
|
private function SetMaster($file) {
|
||||||
$this->master = $file;
|
$this->context[0]['master'] = $file;
|
||||||
}
|
}
|
||||||
private function StartSection($name) {
|
private function StartSection($name) {
|
||||||
$this->currentSection = $name;
|
$this->currentSection = $name;
|
||||||
ob_start();
|
ob_start();
|
||||||
}
|
}
|
||||||
private function EndSection() {
|
private function EndSection() {
|
||||||
$this->sections[$this->currentSection] = ob_get_clean();
|
$this->sections[$this->currentSection] = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
$this->currentSection = false;
|
$this->currentSection = false;
|
||||||
}
|
}
|
||||||
private function GetSection($name) {
|
private function GetSection($name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user