Merge pull request #61 from EvanPurkhiser/fixup/issue-55-layout-renderer

Kostache_Layout: Load content as mustache source
This commit is contained in:
Jeremy Bush 2013-05-22 15:33:07 -07:00
commit 4bc7dc94a2
2 changed files with 17 additions and 8 deletions

View file

@ -40,11 +40,18 @@ class Kohana_Kostache {
{ {
if ($template == NULL) if ($template == NULL)
{ {
$template = explode('_', get_class($class)); $template = $this->_detect_template_path($class);
array_shift($template);
$template = implode('/', $template);
} }
return $this->_engine->loadTemplate($template)->render($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) public function render($class, $template = NULL)
{ {
$this->_engine->setPartials( $content = $this->_engine
array( ->getLoader()
Kostache_Layout::CONTENT_PARTIAL => parent::render($class, $template) ->load($this->_detect_template_path($class));
)
); $this->_engine->setPartials(array(
Kostache_Layout::CONTENT_PARTIAL => $content
));
return $this->_engine->loadTemplate($this->_layout)->render($class); return $this->_engine->loadTemplate($this->_layout)->render($class);
} }