From 8dd2b5b9587f4948eef35663d1423181cc217ac0 Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Mon, 5 Nov 2012 06:34:03 -0600 Subject: [PATCH 1/5] Remove old guide files --- config/userguide.php | 23 ------ guide/kostache/examples.md | 139 ------------------------------------- guide/kostache/index.md | 7 -- guide/kostache/menu.md | 4 -- guide/kostache/usage.md | 58 ---------------- 5 files changed, 231 deletions(-) delete mode 100644 config/userguide.php delete mode 100644 guide/kostache/examples.md delete mode 100644 guide/kostache/index.md delete mode 100644 guide/kostache/menu.md delete mode 100644 guide/kostache/usage.md diff --git a/config/userguide.php b/config/userguide.php deleted file mode 100644 index 353acf1..0000000 --- a/config/userguide.php +++ /dev/null @@ -1,23 +0,0 @@ - array( - - // This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename' - 'kostache' => array( - - // Whether this modules userguide pages should be shown - 'enabled' => TRUE, - - // The name that should show up on the userguide index page - 'name' => 'KOstache', - - // A short description of this module, shown on the index page - 'description' => 'Logic-less View/Mustache Module for Kohana v3', - - // Copyright message, shown in the footer for this module - 'copyright' => 'Zombor', - ) - ) -); \ No newline at end of file diff --git a/guide/kostache/examples.md b/guide/kostache/examples.md deleted file mode 100644 index 6068751..0000000 --- a/guide/kostache/examples.md +++ /dev/null @@ -1,139 +0,0 @@ -# Kostache Examples - -## Complex Example - -Model (This example uses [AutoModeler](http://github.com/zombor/Auto-Modeler)): - - class Model_Test extends AutoModeler - { - protected $_table_name = 'tests'; - - protected $_data = array( - 'id' => '', - 'name' => '', - 'value' => '', - ); - - protected $_rules = array( - 'name' => array('not_empty'), - 'value' => array('not_empty'), - ); - } - -View: - - class View_Example extends Kostache - { - public $title = 'Testing'; - - public function things() - { - return Inflector::plural(get_class(new Model_Test)); - } - - public function tests() - { - $tests = array(); - foreach (AutoModeler::factory('test')->fetch_all() as $test) - { - $tests[] = $test->as_array(); - } - return $tests; - } - } - -Template: - - - - - - {{title}} - - -

{{title}}

-

Here are all my {{things}}:

- - - - -Controller: - - class Controller_Welcome extends Controller { - - public function action_index() - { - echo new View_Example; - } - - } // End Welcome - -## Grabbing a single model value - -Model (This example uses [AutoModeler](http://github.com/zombor/Auto-Modeler)): - - class Model_Test extends AutoModeler - { - protected $_table_name = 'tests'; - - protected $_data = array( - 'id' => '', - 'name' => '', - 'value' => '', - ); - - protected $_rules = array( - 'name' => array('not_empty'), - 'value' => array('not_empty'), - ); - } - -View: - - class View_Singular extends Kostache - { - protected $_pragmas = array(Kostache::PRAGMA_DOT_NOTATION => TRUE); - - public $thing_id = NULL; - public $title = 'Testing'; - - public function thing() - { - return new Model_Test($this->thing_id); - } - } - -Template: - - - - - - {{title}} - - -

{{title}}

-

This is just one thing:

-

{{thing.id}}

- - - - -Controller: - - class Controller_Welcome extends Controller { - - public function action_singular($id) - { - $view = new View_Singular; - $view->thing_id = $id; - echo $view; - } - } // End Welcome diff --git a/guide/kostache/index.md b/guide/kostache/index.md deleted file mode 100644 index 72aefac..0000000 --- a/guide/kostache/index.md +++ /dev/null @@ -1,7 +0,0 @@ -# About Kostache - -Kostache is a Kohana module for using [Mustache](http://defunkt.github.com/mustache/) templates in your application. - -Mustache is a logic-less template class. It is impossible to embed logic into mustache files. - -This module requires mustache.php and includes it as a git submodule. See [Working With Git](tutorials.git) for more information about managing submodules. \ No newline at end of file diff --git a/guide/kostache/menu.md b/guide/kostache/menu.md deleted file mode 100644 index a76cf3f..0000000 --- a/guide/kostache/menu.md +++ /dev/null @@ -1,4 +0,0 @@ -1. **Kostache** - - [About](index) - - [Usage](usage) - - [Examples](examples) \ No newline at end of file diff --git a/guide/kostache/usage.md b/guide/kostache/usage.md deleted file mode 100644 index 9bd0148..0000000 --- a/guide/kostache/usage.md +++ /dev/null @@ -1,58 +0,0 @@ -# Kostache Usage - -View classes go in classes/view/ - -classes/view/example.php - - class View_Example extends Kostache - { - public $foo = 'bar'; - } - -Template files go in templates/ - -templates/example.mustache - - This is a {{foo}} - -In your controller, just do: - - $view = new View_Example; - echo $view; - -And you get: - - "This is a bar" - -## Partials - -To use a partial in your template you use the greater than sign (>) and the name, e.g. {{>header}}. - -You must define partials within the $_partials array in your view class. The key is the name that you use in your template and the value is a path to your partial file. - - protected $_partials = array( - 'header' => 'header', // Loads templates/header.mustache - 'footer' => 'footer/default', // Loads templates/footer/default.mustache - ); - -## Using the Kostache_Layout class - -Kostache comes with a Kostache_Layout class instead of a template controller. This allows your layouts to be more OOP and self contained, and they do not rely on your controllers so much. - -To use it, have your view extend the Kostache_Layout class. You can then specify your own layout file by placing it in templates/layout.mustache. At a minimum, it needs to have a {{>content}} partial defined in it. - -If you have a view that extends the Kostache_Layout class, but wish to render only the template and not the entire layout, you can set the public $render_layout property to FALSE. This is useful if you want to use the same view class for external requests and HMVC requests. - - $view = new View_Post_List; - if ($this->request !== Request::instance) // Is internal request - { - $view->render_layout = FALSE; - } - -## Mustache Documentation - -For specific usage and documentation, see: - -[PHP Mustache](http://github.com/bobthecow/mustache.php) - -[Original Mustache](http://defunkt.github.com/mustache/) \ No newline at end of file From ae75356afaa05d3727ecaa8ad6ed10bc35122883 Mon Sep 17 00:00:00 2001 From: creatoro Date: Mon, 12 Nov 2012 17:43:29 +0100 Subject: [PATCH 2/5] Always use lowercase template filenames. Refs #47. --- 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 49de1c3..8cf09d9 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, $name, $this->_extension); + $filename = Kohana::find_file($this->_base_dir, strtolower($name), $this->_extension); return file_get_contents($filename); } From 5bbdd839fa78d528044d085530cf56fba87ce806 Mon Sep 17 00:00:00 2001 From: Jeremy Bush Date: Tue, 13 Nov 2012 14:42:25 -0600 Subject: [PATCH 3/5] Remove leading period on custom extensions. Fixes #50 --- 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 8cf09d9..27e0769 100644 --- a/classes/Mustache/Loader/Kohana.php +++ b/classes/Mustache/Loader/Kohana.php @@ -13,7 +13,7 @@ class Mustache_Loader_Kohana implements Mustache_Loader, Mustache_Loader_Mutable if (isset($options['extension'])) { - $this->_extension = '.' . ltrim($options['extension'], '.'); + $this->_extension = ltrim($options['extension'], '.'); } } From 4a48b5f7aefaa15fb2f413bc6055dd09218b87cb Mon Sep 17 00:00:00 2001 From: Ando Roots Date: Thu, 22 Nov 2012 13:27:47 +0200 Subject: [PATCH 4/5] Fix links to original mustache in the Readme --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index fe144b7..2b467cf 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ # Kostache -Kostache is a [Kohana 3](https://github.com/kohana/kohana) module for using [Mustache](http://defunkt.github.com/mustache/) templates in your application. +Kostache is a [Kohana 3](https://github.com/kohana/kohana) module for using [Mustache](http://mustache.github.com/) templates in your application. ## Usage @@ -54,4 +54,4 @@ For specific usage and documentation, see: [PHP Mustache](http://github.com/bobthecow/mustache.php) -[Original Mustache](http://defunkt.github.com/mustache/) +[Original Mustache](http://mustache.github.com/) From 74841f65acca0c12ba8c51505ad57473ce340ef8 Mon Sep 17 00:00:00 2001 From: Ando Roots Date: Sun, 30 Dec 2012 19:30:30 +0200 Subject: [PATCH 5/5] Throw Kohana_Exception when Mustache template file not found --- classes/Mustache/Loader/Kohana.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/classes/Mustache/Loader/Kohana.php b/classes/Mustache/Loader/Kohana.php index 49de1c3..9b377d3 100644 --- a/classes/Mustache/Loader/Kohana.php +++ b/classes/Mustache/Loader/Kohana.php @@ -30,6 +30,12 @@ class Mustache_Loader_Kohana implements Mustache_Loader, Mustache_Loader_Mutable protected function _load_file($name) { $filename = Kohana::find_file($this->_base_dir, $name, $this->_extension); + + if ( ! $filename) + { + throw new Kohana_Exception('Mustache template ":name" not found', array(':name' => $name)); + } + return file_get_contents($filename); }