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/classes/Kohana/Kostache.php b/classes/Kohana/Kostache.php index 6f53a9b..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; @@ -23,7 +25,7 @@ class Kohana_Kostache { 'escape' => function($value) { return HTML::chars($value); }, - 'cache' => APPPATH.'cache/mustache', + 'cache' => Kohana::$cache_dir.DIRECTORY_SEPARATOR.'mustache', ) ); @@ -40,11 +42,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); } 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) { 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 @@ -