Ejemplo n.º 1
0
 /**
  * Render a template.
  *
  * The $template argument can be skipped
  *
  * @param string $template
  * @param array $data
  * @return Response
  */
 public function render($template, $data = []) : Response
 {
     if (is_string($template)) {
         $this->view->template($template);
     } else {
         $data = $template;
     }
     return new Response($this->view->render($data));
 }
Ejemplo n.º 2
0
 public function testRenderLayout()
 {
     $view = new View('tests/assets');
     $view['property'] = 'Property';
     $view['title'] = 'Page Title';
     $view->template('view1');
     $view->layout('layout');
     $output = $view->render(['parameter' => 'Parameter']);
     $this->assertRegexp('/<!DOCTYPE/', $output);
     $this->assertRegexp('/<title>Page Title<\\/title>/', $output);
     $this->assertRegexp('/<div>Parameter<\\/div>/', $output);
     $this->assertRegexp('/<div>Property<\\/div>/', $output);
 }