From 57c4b91d8bb4fbbb58ea04ce27c4bb3f13d86b32 Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Sat, 26 Jan 2013 19:16:56 -0600 Subject: [PATCH 1/5] Show correct filename case in template loading error --- classes/Mustache/Loader/Kohana.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Mustache/Loader/Kohana.php b/classes/Mustache/Loader/Kohana.php index 001e7a2..71b23e3 100644 --- a/classes/Mustache/Loader/Kohana.php +++ b/classes/Mustache/Loader/Kohana.php @@ -29,7 +29,7 @@ class Mustache_Loader_Kohana implements Mustache_Loader, Mustache_Loader_Mutable protected function _load_file($name) { - $filename = Kohana::find_file($this->_base_dir, strtolower($name), $this->_extension); + $filename = Kohana::find_file($this->_base_dir, $name = strtolower($name), $this->_extension); if ( ! $filename) { From 598a60b09bbc19bb3afb7819fbe23ab0c612b4c7 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Fri, 15 Mar 2013 19:24:02 -0400 Subject: [PATCH 2/5] 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 --- classes/Kohana/Kostache.php | 13 ++++++++++--- classes/Kohana/Kostache/Layout.php | 12 +++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) 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); } From f766b9c130201ddf0c90776ce7227f7d2dcfd0b9 Mon Sep 17 00:00:00 2001 From: Paul Schwarz Date: Sat, 5 Apr 2014 19:38:48 +0400 Subject: [PATCH 3/5] Uses the proper Kohana cache directory. --- 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 89f53f8..14ea2f6 100644 --- a/classes/Kohana/Kostache.php +++ b/classes/Kohana/Kostache.php @@ -23,7 +23,7 @@ class Kohana_Kostache { 'escape' => function($value) { return HTML::chars($value); }, - 'cache' => APPPATH.'cache/mustache', + 'cache' => Kohana::$cache_dir.DIRECTORY_SEPARATOR.'mustache', ) ); From 9b459a54ad68b6f09423a556e8c6a4162fe2628d Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Fri, 25 Jan 2013 21:49:22 -0700 Subject: [PATCH 4/5] Add Composer support This will allow installing Kostache with Composer. The Mustache.php dependency can be autoloaded - just ensure you are including the Composer autoloader file in your project. --- .gitignore | 1 - .gitmodules | 3 --- composer.json | 25 +++++++++++++++++++++++++ init.php | 5 ----- vendor/mustache | 1 - 5 files changed, 25 insertions(+), 10 deletions(-) delete mode 100644 .gitignore delete mode 100644 .gitmodules create mode 100644 composer.json delete mode 100644 init.php delete mode 160000 vendor/mustache diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1377554..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swp diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fe65ad1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/mustache"] - path = vendor/mustache - url = git://github.com/bobthecow/mustache.php.git diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e1aef3f --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "zombor/kostache", + "description": "Logic-less View/Mustache Module for the Kohana Framework", + "keywords": ["kohana", "mustache", "templating", "view"], + "homepage": "https://github.com/zombor/KOstache", + "license": "MIT", + "authors": [ + { + "name": "Jeremy Bush", + "email": "jeremy.bush@kohanaframework.org" + }, + { + "name": "Woody Gilk", + "email": "woody.gilk@kohanaframework.org" + } + ], + "support": { + "issues": "https://github.com/zombor/KOstache/issues", + "source": "https://github.com/zombor/KOstache" + }, + "require": { + "mustache/mustache": "~2.6.0", + "php": ">=5.3.0" + } +} diff --git a/init.php b/init.php deleted file mode 100644 index b6a24da..0000000 --- a/init.php +++ /dev/null @@ -1,5 +0,0 @@ - Date: Thu, 8 May 2014 09:51:49 -0500 Subject: [PATCH 5/5] Bump version, update docblock --- classes/Kohana/Kostache.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/Kohana/Kostache.php b/classes/Kohana/Kostache.php index 14ea2f6..3c4bfcb 100644 --- a/classes/Kohana/Kostache.php +++ b/classes/Kohana/Kostache.php @@ -5,12 +5,14 @@ * @package Kostache * @category Base * @author Jeremy Bush + * @author Woody Gilk * @copyright (c) 2010-2012 Jeremy Bush + * @copyright (c) 2012-2014 Woody Gilk * @license MIT */ class Kohana_Kostache { - const VERSION = '4.0.0'; + const VERSION = '4.0.3'; protected $_engine;