I have the problem that my data variable is suddenly null. It's happening directly after an IF-Statement when nothing was written to this variable. Does anyone knows what it is happening here?
public function render()
{
ob_start();
if($this->ajax)
$ext = '.ajax';
else if(file_exists($this->scriptPath.$this->template.'.mst'))
$ext = '.mst';
else
$ext = '.phtml';
#var_dump($this->data); // <-- is filled with many data
if($ext === '.mst'){
var_dump($this->data); // <-- is null
$mustache = new \Mustache_Engine(
array(
'escape' => function($value){return $value;},
'partials_loader' => new \Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/../../../frontendTarget/classes/lib/de/preis/frontend/viewFragments/partials',array('extension' => 'mst'))
)
);
$content = file_get_contents($this->scriptPath.$this->template.$ext);
$content = $mustache->render(($content),$this->data);
echo $content;
} else {
include $this->scriptPath.$this->template.$ext;
}
return ob_get_clean();
}
I've here two var_dumps(). One before the if, where the var is filled with data and one after the if, where the data is suddenly completely gone.
Could anyone assist me on this one? Thanks in advance
var_dump($this->data);return data, what is the value of$ext? Maybe when the value is'.mst'there is no datavar_dump()so both of them dump their data, are you getting the first with data and the second displays null? or are you running the code twice commenting eachvar_dump()in/out so you only execute 1 of them?var_dumpin and one out. I just ran it again with both in and realized that I get the output of the first one with data and a 2nd output of the first one where it is empty. Maybe you got a good point here. I will follow up with this new information.