public function testEventTagNotConnected() { $request = (object) array(); $renderer = new template\Renderer('data-template-event-tag.html', array(__DIR__)); $ctx = new template\ContextRequest($request, array()); $out = $renderer->render($ctx); $this->assertequals("\n", $out); }
/** * Render a template file and an array as a reponse. * * @param $tmpl Template file name * @param $context Associative array for the context * @return Rendered template as a string */ public static function RenderToString($tmpl, $context) { $renderer = new ptemplate\Renderer($tmpl, Conf::f('template_folders')); $context = new ptemplate\Context($context); return $renderer->render($context); }
function __construct($exception, $mimetype = null) { $this->exception = $exception; $content = ''; $admins = Conf::f('admins', array()); if (count($admins) > 0) { // Get a nice stack trace and send it by emails. $stack = pretty_server_error($exception); $subject = $exception->getMessage(); $subject = substr(strip_tags(nl2br($subject)), 0, 50) . '...'; foreach ($admins as $admin) { $email = new Mail($admin[1], $admin[1], $subject); $email->addTextMessage($stack); $email->sendMail(); } } try { $context = new template\Context(array('message' => $exception->getMessage())); $renderer = new template\Renderer('500.html'); $content = $renderer->render($context); $mimetype = null; } catch (\Exception $e) { $mimetype = 'text/plain'; $content = 'The server encountered an unexpected condition which prevented it from fulfilling your request.' . "\n\n" . 'An email has been sent to the administrators, we will correct this error as soon as possible. Thank you for your comprehension.' . "\n\n" . '500 - Internal Server Error'; } parent::__construct($content, $mimetype); $this->status_code = 500; }