- new methods parse and p (for print) : enable PhpWebGallery pages to be

fully generated before being send to browser


git-svn-id: http://piwigo.org/svn/trunk@687 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
plegall
2005-01-11 21:44:31 +00:00
parent 037885d2f3
commit 57475d91be
+36
View File
@@ -55,6 +55,9 @@ class Template {
// This will hold the uncompiled code for that handle.
var $uncompiled_code = array();
// output
var $output = '';
/**
* Constructor. Simply sets the root dir.
@@ -133,6 +136,39 @@ class Template {
eval($this->compiled_code[$handle]);
return true;
}
/**
* fills $output template var
*/
function parse($handle)
{
if (!$this->loadfile($handle))
{
die("Template->pparse(): Couldn't load template file for handle $handle");
}
// actually compile the template now.
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
{
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle], true, '_str');
}
// Run the compiled code.
$_str = '';
eval($this->compiled_code[$handle]);
$this->output.= $_str;
return true;
}
/**
* prints $output template var
*/
function p()
{
echo $this->output;
}
/**
* Inserts the uncompiled code for $handle as the value of $varname in the