/** * Render the item using the current global rendering context, and return it * as a string. * * @return string */ public function render() { # Call Renderable::render() for content items as necessary to ensure they are all strings. foreach ($this->content as &$content) { if (!$content instanceof Renderable) { continue; } $content = $content->render(); } unset($content); # break last element reference. # restart content iterator if (!is_null($this->contentIterator)) { $this->contentIterator = null; } # Call default render method. return parent::render(); }
/** * Fail if a template file doesn't exist at render time. * * @todo This behaviour may change when automatic per-context templates are implemented */ public function testInvalidRenderTemplate() { touch(AbstractTemplate::getPath() . 'foo-fail.tpl.php'); $t = new Template('foo-fail'); unlink(AbstractTemplate::getPath() . 'foo-fail.tpl.php'); try { $t->render(); $this->fail(); } catch (\RuntimeException $e) { } }
/** * */ public function setUp() { AbstractTemplate::setPath(DATA_DIR . 'templates'); }