From d264ef940ccdf038487bc3ef828b8fbf481d1719 Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Tue, 11 Jan 2011 11:36:22 -0600 Subject: [PATCH 1/3] Updating for 3.1 api --- classes/kohana/kostache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/kohana/kostache.php b/classes/kohana/kostache.php index 9dea279..c69e5c1 100644 --- a/classes/kohana/kostache.php +++ b/classes/kohana/kostache.php @@ -115,7 +115,7 @@ class Kohana_Kostache extends Mustache catch (Exception $e) { // Display the exception message - Kohana::exception_handler($e); + Kohana_Exception::handler($e); return ''; } From 553d8dda0746c6e33f4b2efb2398a94342b6aa69 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Fri, 25 Feb 2011 10:29:07 -0500 Subject: [PATCH 2/3] Kohana 3.1 compatibility --- classes/kohana/kostache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/kohana/kostache.php b/classes/kohana/kostache.php index 8fa6bf3..d366758 100644 --- a/classes/kohana/kostache.php +++ b/classes/kohana/kostache.php @@ -87,7 +87,7 @@ abstract class Kohana_Kostache { ob_start(); // Render the exception - Kohana::exception_text($e); + Kohana_Exception::text($e); return (string) ob_get_clean(); } From 58c26155eeb4a4beb97fe73ebf4ac4f7b683ba4d Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Mon, 14 Mar 2011 14:17:34 -0500 Subject: [PATCH 3/3] Added missing template detection when using "new View_Foo" instead of "Kostache::factory(foo)" --- classes/kohana/kostache.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/classes/kohana/kostache.php b/classes/kohana/kostache.php index 6136078..14e022e 100644 --- a/classes/kohana/kostache.php +++ b/classes/kohana/kostache.php @@ -56,8 +56,14 @@ abstract class Kohana_Kostache { * @uses Kostache::template * @uses Kostache::partial */ - public function __construct($template, array $partials = NULL) + public function __construct($template = NULL, array $partials = NULL) { + if ( ! $template) + { + // Detect the template for this class + $template = $this->_detect_template(); + } + // Load the template $this->template($template); @@ -233,4 +239,23 @@ abstract class Kohana_Kostache { return file_get_contents($file); } + /** + * Detect the template name from the class name. + * + * @return string + */ + protected function _detect_template() + { + // Start creating the template path from the class name + $template = explode('_', get_class($this)); + + // Remove "View" prefix + array_shift($template); + + // Convert name parts into a path + $template = strtolower(implode('/', $template)); + + return $template; + } + }