コード例 #1
0
ファイル: LoggableView.php プロジェクト: gigablah/silex-view
 /**
  * {@inheritDoc}
  */
 public function render($context = array())
 {
     if (null === $this->logger) {
         return parent::render($context);
     }
     $this->logger->startRender($this);
     $content = parent::render($context);
     $this->logger->stopRender($this);
     return $content;
 }
コード例 #2
0
 public function testRenderCompositeViews()
 {
     $htmlView = new View(__DIR__ . '/Fixtures/foobar.html', array(), $this->engine, $this->sharedBag, $this->exceptionBag);
     $mustacheView = new View('foobar.mustache', array('title' => $htmlView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $smartyView = new View('foobar.tpl', array('title' => $mustacheView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $twigView = new View('foobar.twig', array('title' => $smartyView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $nestView = clone $htmlView;
     $twigView->nest($nestView->with(array('{{title}}' => 'bar')), 'title');
     $phpView = new View(__DIR__ . '/Fixtures/foobar.php', array('title' => $twigView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $phpView->share(array('{{title}}' => 'foo'));
     $this->assertEquals('<h1><h1><h1><h1><h1>foo</h1></h1></h1><h1>bar</h1></h1></h1>', $phpView->render());
 }
コード例 #3
0
ファイル: ViewTest.php プロジェクト: gigablah/silex-view
 public function testContextInheritance()
 {
     $htmlView = new View(__DIR__ . '/Fixtures/foobar.html', array(), $this->engine, $this->sharedBag, $this->exceptionBag);
     $mustacheView = new View('foobar.mustache', array('title' => $htmlView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $smartyView = new View('foobar.tpl', array('title' => $mustacheView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $twigView = new View('foobar.twig', array('title' => $smartyView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $phpView = new View(__DIR__ . '/Fixtures/foobar.php', array('title' => $twigView), $this->engine, $this->sharedBag, $this->exceptionBag);
     $phpView['{{title}}'] = 'foo';
     $this->assertEquals('<h1><h1><h1><h1><h1>foo</h1></h1></h1></h1></h1>', $phpView->render());
 }