For more information about implementing your own template loaders or renderers, see the lithium\template\View class.
См. также: lithium\template\View
См. также: lithium\template\view\Compiler
Наследование: extends lithium\template\view\Renderer
Пример #1
0
 public function testInvalidTemplateType()
 {
     $file = new File(array('compile' => false, 'paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php')));
     $this->assertException("Invalid template type 'invalid'.", function () use($file) {
         $file->template('invalid', array('template' => 'foo'));
     });
 }
Пример #2
0
 public function testTemplateLocating()
 {
     $file = new File(array('paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php')));
     $template = $file->template('template', array('controller' => 'pages', 'template' => 'home', 'type' => 'html'));
     $this->assertPattern('/template_views_pages_home\\.html_[0-9]+/', $template);
     $file = new File(array('compile' => false, 'paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php')));
     $template = $file->template('template', array('controller' => 'pages', 'template' => 'home', 'type' => 'html'));
     $this->assertPattern('/\\/views\\/pages\\/home\\.html\\.php$/', $template);
     $template = $file->template('invalid', array('template' => 'foo'));
     $this->assertNull($template);
     $this->expectException('/Template not found/');
     $file->template('template', array('controller' => 'pages', 'template' => 'foo', 'type' => 'html'));
 }
Пример #3
0
 public function __construct(array $config = array())
 {
     $defaults = array('classes' => array(), 'compile' => true, 'extract' => true, 'paths' => array());
     parent::__construct($config + $defaults);
     // Start the hierarchy lexer
     Lexer::_init(array('hierarchy' => $this));
 }
Пример #4
0
 /**
  * Renderer constructor.
  *
  * Accepts these following configuration parameters:
  * - `view`: The `View` object associated with this renderer.
  * - `strings`: String templates used by helpers.
  * - `handlers`: An array of output handlers for string template inputs.
  * - `message`: The `Message` object associated with this renderer.
  * - `context`: An array of the current rendering context data, like `content`.
  *
  * @param array $config
  */
 public function __construct(array $config = array())
 {
     $defaults = array('message' => null, 'context' => array('content' => '', 'scripts' => array(), 'styles' => array(), 'head' => array()));
     parent::__construct((array) $config + $defaults);
 }