Skip to content

Commit

Permalink
Merge pull request #61 from EvanPurkhiser/fixup/issue-55-layout-renderer
Browse files Browse the repository at this point in the history
Kostache_Layout: Load content as mustache source
  • Loading branch information
zombor committed May 22, 2013
2 parents 57c4b91 + 598a60b commit 4bc7dc9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 10 additions & 3 deletions classes/Kohana/Kostache.php
Expand Up @@ -40,11 +40,18 @@ public function render($class, $template = NULL)
{
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);
}

}
12 changes: 7 additions & 5 deletions classes/Kohana/Kostache/Layout.php
Expand Up @@ -34,11 +34,13 @@ public function set_layout($layout)

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);
}
Expand Down

1 comment on commit 4bc7dc9

@eXpl0it3r
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $template parameter for the layout render function should either get removed or used inside the function, because currently it's just there as decoration..

Please sign in to comment.