Add render_layout property and update documentation.
This commit is contained in:
parent
4a3277020b
commit
56ab985be7
|
@ -205,6 +205,14 @@ KOstache comes with a View_Layout class instead of a template controller. This a
|
|||
|
||||
To use it, have your view extend the View_Layout class. You can then specify your own layout file by placing it in templates/layout.mustache. At a minimum, it needs to have a {{>body}} partial defined in it.
|
||||
|
||||
If you have a view that extends the View_Layout class, but wish to render only the template and not the entire layout, you can set the public $render_layout property to FALSE. This is useful if you want to use the same view class for external requests and HMVC requests.
|
||||
|
||||
$view = new View_Post_List;
|
||||
if ($this->request !== Request::instance) // Is internal request
|
||||
{
|
||||
$view->render_layout = FALSE;
|
||||
}
|
||||
|
||||
For specific usage and documentation, see:
|
||||
|
||||
[PHP Mustache](http://github.com/bobthecow/mustache.php)
|
||||
|
|
|
@ -4,6 +4,8 @@ class View_Kohana_Layout extends Kostache
|
|||
{
|
||||
protected $_layout = 'layout';
|
||||
|
||||
public $render_layout = TRUE;
|
||||
|
||||
/**
|
||||
* @var string template title
|
||||
*/
|
||||
|
@ -22,12 +24,15 @@ class View_Kohana_Layout extends Kostache
|
|||
$this->_template = strtolower(implode(DIRECTORY_SEPARATOR, $foo));
|
||||
}
|
||||
|
||||
$this->_partials+=array(
|
||||
'body' => $this->_template
|
||||
);
|
||||
if ($this->render_layout)
|
||||
{
|
||||
$this->_partials+=array(
|
||||
'body' => $this->_template
|
||||
);
|
||||
|
||||
// Make the layout view the child class's template
|
||||
$this->_template = $this->_layout;
|
||||
// Make the layout view the child class's template
|
||||
$this->_template = $this->_layout;
|
||||
}
|
||||
|
||||
return parent::render($template, $view, $partials);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,15 @@ You must define partials within the $_partials array in your view class. The ke
|
|||
|
||||
KOstache comes with a View_Layout class instead of a template controller. This allows your layouts to be more OOP and self contained, and they do not rely on your controllers so much.
|
||||
|
||||
To use it, have your view extend the View_Layout class. You can then specify your own layout file by placing it in templates/layout.mustache. At a minimum, it needs to have a {{>body}} partial defined in it.
|
||||
To use it, have your view extend the View_Layout class. You can then specify your own layout file by placing it in templates/layout.mustache. At a minimum, it needs to have a {{>body}}; partial defined in it.
|
||||
|
||||
If you have a view that extends the View_Layout class, but wish to render only the template and not the entire layout, you can set the public $render_layout property to FALSE. This is useful if you want to use the same view class for external requests and HMVC requests.
|
||||
|
||||
$view = new View_Post_List;
|
||||
if ($this->request !== Request::instance) // Is internal request
|
||||
{
|
||||
$view->render_layout = FALSE;
|
||||
}
|
||||
|
||||
## Mustache Documentation
|
||||
|
||||
|
|
Loading…
Reference in a new issue