lithium\template\view\adapter\File::template PHP Method

template() public method

Returns a template file name
public template ( string $type, array $params ) : string
$type string
$params array
return string
    public function template($type, array $params)
    {
        $library = Libraries::get(isset($params['library']) ? $params['library'] : true);
        $params['library'] = $library['path'];
        $path = $this->_paths($type, $params);
        if ($this->_compile) {
            $compiler = $this->_classes['compiler'];
            $path = $compiler::template($path, $this->_config['compiler']);
        }
        return $path;
    }

Usage Example

Example #1
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'));
 }
All Usage Examples Of lithium\template\view\adapter\File::template