$Part) { $ClassNameParts[$Index] = ucfirst($Part); } $ClassName = implode($ClassNameParts). 'Template'; $LoadedTemplates[$TemplateName] = $ClassName; } $ClassName::render($Args); } /** * This method is similar to render_template, but does not require a * template class. * * Instead, this method simply renders a PHP file (PHTML) with the supplied * variables. * * All files must be placed within {self::IncludePath}. Create and organize * new paths and files. (e.g.: /design/views/artist/, design/view/forums/, etc.) * * @static * @param string $TemplateFile A relative path to a PHTML file * @param array $Variables Assoc. array of variables to extract for the template * @param boolean $Buffer enables Output Buffer * @return boolean|string * * @example
">Data
*
* // The variable $id within box.phtml will be filled by $some_id
* View::parse('section/box.phtml', array('id' => $some_id));
*
* // Parse a template without outputing it
* $SavedTemplate = View::parse('sec/tion/eg.php', $DataArray, true);
* // later . . .
* echo $SavedTemplate; // Output the buffer
*
*/
public static function parse($TemplateFile, array $Variables = [], $Buffer = false) {
$Template = self::IncludePath . $TemplateFile;
if (file_exists($Template)) {
extract($Variables);
if ($Buffer) {
ob_start();
include $Template;
$Content = ob_get_contents();
ob_end_clean();
return $Content;
}
return include $Template;
}
}
}