1
0
Fork 0

Kostache_Layout: Load content as mustache source

This fixes issues caused by the content partial being rendered and then
injected as a partial in the layout template and being rendered again
This commit is contained in:
Evan Purkhiser 2013-03-15 19:24:02 -04:00
parent 57c4b91d8b
commit 598a60b09b
2 changed files with 17 additions and 8 deletions

View File

@ -40,11 +40,18 @@ class Kohana_Kostache {
{
if ($template == NULL)
{
$template = explode('_', get_class($class));
array_shift($template);
$template = implode('/', $template);
$template = $this->_detect_template_path($class);
}
return $this->_engine->loadTemplate($template)->render($class);
}
protected function _detect_template_path($class)
{
$path = explode('_', get_class($class));
array_shift($path);
return implode('/', $path);
}
}

View File

@ -34,11 +34,13 @@ class Kohana_Kostache_Layout extends Kohana_Kostache {
public function render($class, $template = NULL)
{
$this->_engine->setPartials(
array(
Kostache_Layout::CONTENT_PARTIAL => parent::render($class, $template)
)
);
$content = $this->_engine
->getLoader()
->load($this->_detect_template_path($class));
$this->_engine->setPartials(array(
Kostache_Layout::CONTENT_PARTIAL => $content
));
return $this->_engine->loadTemplate($this->_layout)->render($class);
}