mirror of
https://github.com/filp/whoops.git
synced 2026-09-15 04:06:17 +00:00
Add TemplateHelper::render
This commit is contained in:
@@ -126,14 +126,12 @@ class PrettyPageHandler extends Handler
|
||||
// Add extra entries list of data tables:
|
||||
$v->tables = array_merge($extraTables, $v->tables);
|
||||
|
||||
call_user_func(function() use($templateFile, $v, $helper) {
|
||||
// $e -> cleanup output, optionally preserving URIs as anchors:
|
||||
$e = array($helper, "escape");
|
||||
$slug = array($helper, "slug");
|
||||
|
||||
require $templateFile;
|
||||
});
|
||||
// Temp:
|
||||
$vars["e"] = array($helper, "escape");
|
||||
$vars["slug"] = array($helper, "slug");
|
||||
$vars["v"] = $v;
|
||||
|
||||
$helper->render($templateFile, $vars);
|
||||
|
||||
return Handler::QUIT;
|
||||
}
|
||||
|
||||
@@ -50,4 +50,21 @@ class TemplateHelper
|
||||
$slug = preg_replace('/[^\w\d\-\_]/i', '', $slug);
|
||||
return strtolower($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a template path, render it within its own scope.
|
||||
*
|
||||
* @param string $__template
|
||||
* @param array $__variables
|
||||
*/
|
||||
public function render($__template, array $__variables = array())
|
||||
{
|
||||
// Pass the helper to the template:
|
||||
$__variables["tpl"] = $this;
|
||||
|
||||
call_user_func(function() use($__template, $__variables) {
|
||||
extract($__variables);
|
||||
require $__template;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user