diff --git a/classes/Kohana/Kostache.php b/classes/Kohana/Kostache.php index 6f53a9b..89f53f8 100644 --- a/classes/Kohana/Kostache.php +++ b/classes/Kohana/Kostache.php @@ -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); + } + } diff --git a/classes/Kohana/Kostache/Layout.php b/classes/Kohana/Kostache/Layout.php index 1f85dc1..7627a6b 100644 --- a/classes/Kohana/Kostache/Layout.php +++ b/classes/Kohana/Kostache/Layout.php @@ -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); }