Add static InlineRender method to CPHP Templater

feature/node-rewrite
Sven Slootweg 13 years ago
parent a7408bd659
commit 70a5fb56a5

@ -120,4 +120,13 @@ class Templater
Throw new Exception("No template loaded."); Throw new Exception("No template loaded.");
} }
} }
public static function InlineRender($templatename, $localize = array(), $compile = array())
{
$template = new Templater();
$template->Load($templatename);
$template->Localize($localize);
$template->Compile($compile);
return $template->Render();
}
} }

@ -8,10 +8,7 @@ $settings['salt'] = "kAU0qM";
$sContainer = new Container(1); $sContainer = new Container(1);
$template_main = new Templater(); echo(Templater::InlineRender("main", $locale->strings, array(
$template_main->Load("main");
$template_main->Localize($locale->strings);
$template_main->Compile(array(
'server-location' => $sContainer->sNode->sPhysicalLocation, 'server-location' => $sContainer->sNode->sPhysicalLocation,
'operating-system' => $sContainer->sTemplate->sName, 'operating-system' => $sContainer->sTemplate->sName,
'guaranteed-ram' => "{$sContainer->sGuaranteedRam}MB", 'guaranteed-ram' => "{$sContainer->sGuaranteedRam}MB",
@ -19,7 +16,6 @@ $template_main->Compile(array(
'disk-space' => "{$sContainer->sDiskSpace}MB", 'disk-space' => "{$sContainer->sDiskSpace}MB",
'total-traffic-limit' => "{$sContainer->sTotalTrafficLimit} bytes", 'total-traffic-limit' => "{$sContainer->sTotalTrafficLimit} bytes",
'bandwidth-limit' => "100mbit", 'bandwidth-limit' => "100mbit",
)); )));
$template_main->Output();
?> ?>

Loading…
Cancel
Save