From 1d116d1b77acdff346c6a835a98ad320e0c8b6e4 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 29 Feb 2012 18:02:16 -0800 Subject: [PATCH] Update `examples` for v2.0 --- examples/child_context/ChildContext.php | 6 +++--- examples/comments/Comments.php | 4 ++-- examples/complex/complex.php | 4 ++-- examples/delimiters/Delimiters.php | 4 ++-- examples/dot_notation/DotNotation.php | 12 +++--------- examples/dot_notation/dot_notation.mustache | 3 +-- examples/dot_notation/dot_notation.txt | 3 +-- examples/double_section/DoubleSection.php | 4 ++-- examples/escaped/Escaped.php | 4 ++-- .../GrandParentContext.php | 12 +++++------- examples/i18n/I18n.php | 8 ++++---- .../implicit_iterator/ImplicitIterator.php | 6 +++--- .../InvertedDoubleSection.php | 4 ++-- examples/inverted_section/InvertedSection.php | 4 ++-- .../inverted_section.mustache | 8 ++++++-- .../inverted_section/inverted_section.txt | 2 +- examples/partials/Partials.php | 8 ++------ examples/partials/partials/children.mustache | 2 ++ .../PartialsWithViewClass.php | 19 ------------------- .../partials_with_view_class.mustache | 2 -- .../partials_with_view_class.txt | 3 --- examples/pragma_unescaped/PragmaUnescaped.php | 5 ----- .../pragma_unescaped.mustache | 3 --- .../pragma_unescaped/pragma_unescaped.txt | 2 -- .../pragmas_in_partials/PragmasInPartials.php | 8 -------- .../pragmas_in_partials.mustache | 3 --- .../pragmas_in_partials.txt | 2 -- .../recursive_partials/RecursivePartials.php | 8 ++------ .../partials/child.mustache | 1 + .../SectionIteratorObjects.php | 4 ++-- .../SectionMagicObjects.php | 4 ++-- examples/section_objects/SectionObjects.php | 4 ++-- examples/sections/Sections.php | 4 ++-- examples/sections_nested/SectionsNested.php | 4 ++-- examples/simple/Simple.php | 4 ++-- examples/unescaped/Unescaped.php | 4 ++-- examples/utf8/UTF8.php | 4 ++-- examples/utf8_unescaped/UTF8Unescaped.php | 4 ++-- examples/whitespace/Whitespace.php | 10 ++-------- .../whitespace/partials/alphabet.mustache | 1 + 40 files changed, 69 insertions(+), 132 deletions(-) create mode 100644 examples/partials/partials/children.mustache delete mode 100644 examples/partials_with_view_class/PartialsWithViewClass.php delete mode 100644 examples/partials_with_view_class/partials_with_view_class.mustache delete mode 100644 examples/partials_with_view_class/partials_with_view_class.txt delete mode 100644 examples/pragma_unescaped/PragmaUnescaped.php delete mode 100644 examples/pragma_unescaped/pragma_unescaped.mustache delete mode 100644 examples/pragma_unescaped/pragma_unescaped.txt delete mode 100644 examples/pragmas_in_partials/PragmasInPartials.php delete mode 100644 examples/pragmas_in_partials/pragmas_in_partials.mustache delete mode 100644 examples/pragmas_in_partials/pragmas_in_partials.txt create mode 100644 examples/recursive_partials/partials/child.mustache create mode 100644 examples/whitespace/partials/alphabet.mustache diff --git a/examples/child_context/ChildContext.php b/examples/child_context/ChildContext.php index b652356..95eb5a6 100644 --- a/examples/child_context/ChildContext.php +++ b/examples/child_context/ChildContext.php @@ -1,13 +1,13 @@ 'child works', ); - + public $grandparent = array( 'parent' => array( 'child' => 'grandchild works', ), ); -} \ No newline at end of file +} diff --git a/examples/comments/Comments.php b/examples/comments/Comments.php index 7f028ba..6eb7da1 100644 --- a/examples/comments/Comments.php +++ b/examples/comments/Comments.php @@ -1,7 +1,7 @@ item) === 0; } -} \ No newline at end of file +} diff --git a/examples/delimiters/Delimiters.php b/examples/delimiters/Delimiters.php index be372fa..4dac04d 100644 --- a/examples/delimiters/Delimiters.php +++ b/examples/delimiters/Delimiters.php @@ -1,6 +1,6 @@ array('first' => 'Chris', 'last' => 'Firescythe'), 'age' => 24, - 'hobbies' => array('Cycling', 'Fishing'), 'hometown' => array( - 'city' => 'Cincinnati', + 'city' => 'Cincinnati', 'state' => 'OH', - ), + ) ); public $normal = 'Normal'; diff --git a/examples/dot_notation/dot_notation.mustache b/examples/dot_notation/dot_notation.mustache index 0135a2a..0566867 100644 --- a/examples/dot_notation/dot_notation.mustache +++ b/examples/dot_notation/dot_notation.mustache @@ -1,5 +1,4 @@ * {{person.name.first}} {{person.name.last}} * {{person.age}} -* {{person.hobbies.0}}, {{person.hobbies.1}} * {{person.hometown.city}}, {{person.hometown.state}} -* {{normal}} +* {{normal}} \ No newline at end of file diff --git a/examples/dot_notation/dot_notation.txt b/examples/dot_notation/dot_notation.txt index e5c1ed9..f8cf1fa 100644 --- a/examples/dot_notation/dot_notation.txt +++ b/examples/dot_notation/dot_notation.txt @@ -1,5 +1,4 @@ * Chris Firescythe * 24 -* Cycling, Fishing * Cincinnati, OH -* Normal +* Normal \ No newline at end of file diff --git a/examples/double_section/DoubleSection.php b/examples/double_section/DoubleSection.php index f9d3dbb..31fdfc5 100644 --- a/examples/double_section/DoubleSection.php +++ b/examples/double_section/DoubleSection.php @@ -1,9 +1,9 @@ "Shark"'; -} \ No newline at end of file +} diff --git a/examples/grand_parent_context/GrandParentContext.php b/examples/grand_parent_context/GrandParentContext.php index 5a59ed9..6829372 100644 --- a/examples/grand_parent_context/GrandParentContext.php +++ b/examples/grand_parent_context/GrandParentContext.php @@ -1,24 +1,22 @@ parent_contexts[] = array('parent_id' => 'parent1', 'child_contexts' => array( array('child_id' => 'parent1-child1'), array('child_id' => 'parent1-child2') )); - + $parent2 = new stdClass(); $parent2->parent_id = 'parent2'; $parent2->child_contexts = array( array('child_id' => 'parent2-child1'), array('child_id' => 'parent2-child2') ); - + $this->parent_contexts[] = $parent2; } -} \ No newline at end of file +} diff --git a/examples/i18n/I18n.php b/examples/i18n/I18n.php index 980e649..73cdd74 100644 --- a/examples/i18n/I18n.php +++ b/examples/i18n/I18n.php @@ -1,6 +1,6 @@ 'Hola.', 'My name is {{ name }}.' => 'Me llamo {{ name }}.', ); public function __trans($text) { - return isset($this->dictionary[$text]) ? $this->dictionary[$text] : $text; + return isset(self::$dictionary[$text]) ? self::$dictionary[$text] : $text; } -} \ No newline at end of file +} diff --git a/examples/implicit_iterator/ImplicitIterator.php b/examples/implicit_iterator/ImplicitIterator.php index c01fef0..d52ac58 100644 --- a/examples/implicit_iterator/ImplicitIterator.php +++ b/examples/implicit_iterator/ImplicitIterator.php @@ -1,5 +1,5 @@ {{name}}{{/repo}} -{{^repo}}No repos :({{/repo}} \ No newline at end of file +{{#repo}} + {{name}} +{{/repo}} +{{^repo}} + No repos :( +{{/repo}} \ No newline at end of file diff --git a/examples/inverted_section/inverted_section.txt b/examples/inverted_section/inverted_section.txt index 2b9ed3f..6ba5a99 100644 --- a/examples/inverted_section/inverted_section.txt +++ b/examples/inverted_section/inverted_section.txt @@ -1 +1 @@ -No repos :( \ No newline at end of file + No repos :( diff --git a/examples/partials/Partials.php b/examples/partials/Partials.php index 093257b..19f627a 100644 --- a/examples/partials/Partials.php +++ b/examples/partials/Partials.php @@ -1,13 +1,9 @@ 'federica', 'age' => 27, 'gender' => 'female'), array('name' => 'marco', 'age' => 32, 'gender' => 'male'), ); - - protected $_partials = array( - 'children' => "{{#data}}{{name}} - {{age}} - {{gender}}\n{{/data}}", - ); -} \ No newline at end of file +} diff --git a/examples/partials/partials/children.mustache b/examples/partials/partials/children.mustache new file mode 100644 index 0000000..9506a28 --- /dev/null +++ b/examples/partials/partials/children.mustache @@ -0,0 +1,2 @@ +{{#data}}{{name}} - {{age}} - {{gender}} +{{/data}} \ No newline at end of file diff --git a/examples/partials_with_view_class/PartialsWithViewClass.php b/examples/partials_with_view_class/PartialsWithViewClass.php deleted file mode 100644 index 56e0d86..0000000 --- a/examples/partials_with_view_class/PartialsWithViewClass.php +++ /dev/null @@ -1,19 +0,0 @@ -name = 'ilmich'; - $view->data = array( - array('name' => 'federica', 'age' => 27, 'gender' => 'female'), - array('name' => 'marco', 'age' => 32, 'gender' => 'male'), - ); - - $partials = array( - 'children' => "{{#data}}{{name}} - {{age}} - {{gender}}\n{{/data}}", - ); - - parent::__construct($template, $view, $partials); - } -} \ No newline at end of file diff --git a/examples/partials_with_view_class/partials_with_view_class.mustache b/examples/partials_with_view_class/partials_with_view_class.mustache deleted file mode 100644 index 037e1b3..0000000 --- a/examples/partials_with_view_class/partials_with_view_class.mustache +++ /dev/null @@ -1,2 +0,0 @@ -Children of {{name}}: -{{>children}} \ No newline at end of file diff --git a/examples/partials_with_view_class/partials_with_view_class.txt b/examples/partials_with_view_class/partials_with_view_class.txt deleted file mode 100644 index d967e15..0000000 --- a/examples/partials_with_view_class/partials_with_view_class.txt +++ /dev/null @@ -1,3 +0,0 @@ -Children of ilmich: -federica - 27 - female -marco - 32 - male diff --git a/examples/pragma_unescaped/PragmaUnescaped.php b/examples/pragma_unescaped/PragmaUnescaped.php deleted file mode 100644 index b4e0e21..0000000 --- a/examples/pragma_unescaped/PragmaUnescaped.php +++ /dev/null @@ -1,5 +0,0 @@ - Shark'; -} \ No newline at end of file diff --git a/examples/pragma_unescaped/pragma_unescaped.mustache b/examples/pragma_unescaped/pragma_unescaped.mustache deleted file mode 100644 index 76095d7..0000000 --- a/examples/pragma_unescaped/pragma_unescaped.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{%UNESCAPED}} -{{vs}} -{{{vs}}} \ No newline at end of file diff --git a/examples/pragma_unescaped/pragma_unescaped.txt b/examples/pragma_unescaped/pragma_unescaped.txt deleted file mode 100644 index 2860f61..0000000 --- a/examples/pragma_unescaped/pragma_unescaped.txt +++ /dev/null @@ -1,2 +0,0 @@ -Bear > Shark -Bear > Shark \ No newline at end of file diff --git a/examples/pragmas_in_partials/PragmasInPartials.php b/examples/pragmas_in_partials/PragmasInPartials.php deleted file mode 100644 index 7458289..0000000 --- a/examples/pragmas_in_partials/PragmasInPartials.php +++ /dev/null @@ -1,8 +0,0 @@ -'; - protected $_partials = array( - 'dinosaur' => '{{say}}' - ); -} \ No newline at end of file diff --git a/examples/pragmas_in_partials/pragmas_in_partials.mustache b/examples/pragmas_in_partials/pragmas_in_partials.mustache deleted file mode 100644 index abd6ef4..0000000 --- a/examples/pragmas_in_partials/pragmas_in_partials.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{%UNESCAPED}} -{{say}} -{{>dinosaur}} \ No newline at end of file diff --git a/examples/pragmas_in_partials/pragmas_in_partials.txt b/examples/pragmas_in_partials/pragmas_in_partials.txt deleted file mode 100644 index c8e77e3..0000000 --- a/examples/pragmas_in_partials/pragmas_in_partials.txt +++ /dev/null @@ -1,2 +0,0 @@ -< RAWR!! > -< RAWR!! > \ No newline at end of file diff --git a/examples/recursive_partials/RecursivePartials.php b/examples/recursive_partials/RecursivePartials.php index 04e8af8..b3c5f56 100644 --- a/examples/recursive_partials/RecursivePartials.php +++ b/examples/recursive_partials/RecursivePartials.php @@ -1,10 +1,6 @@ " > {{ name }}{{#child}}{{>child}}{{/child}}", - ); - +class RecursivePartials { public $name = 'George'; public $child = array( 'name' => 'Dan', @@ -13,4 +9,4 @@ class RecursivePartials extends Mustache { 'child' => false, ) ); -} \ No newline at end of file +} diff --git a/examples/recursive_partials/partials/child.mustache b/examples/recursive_partials/partials/child.mustache new file mode 100644 index 0000000..1282941 --- /dev/null +++ b/examples/recursive_partials/partials/child.mustache @@ -0,0 +1 @@ + > {{ name }}{{#child}}{{>child}}{{/child}} \ No newline at end of file diff --git a/examples/section_iterator_objects/SectionIteratorObjects.php b/examples/section_iterator_objects/SectionIteratorObjects.php index 7b65597..9a14418 100644 --- a/examples/section_iterator_objects/SectionIteratorObjects.php +++ b/examples/section_iterator_objects/SectionIteratorObjects.php @@ -1,6 +1,6 @@ _data[$key]); } -} \ No newline at end of file +} diff --git a/examples/section_objects/SectionObjects.php b/examples/section_objects/SectionObjects.php index 41b7d84..8d9f101 100644 --- a/examples/section_objects/SectionObjects.php +++ b/examples/section_objects/SectionObjects.php @@ -1,6 +1,6 @@ Shark"; -} \ No newline at end of file +} diff --git a/examples/utf8/UTF8.php b/examples/utf8/UTF8.php index 7843f53..258fa70 100644 --- a/examples/utf8/UTF8.php +++ b/examples/utf8/UTF8.php @@ -1,5 +1,5 @@ tag }}` and `{{> tag}}` and `{{>tag}}` should all be equivalent. - * - * @extends Mustache */ -class Whitespace extends Mustache { +class Whitespace { public $foo = 'alpha'; public $bar = 'beta'; @@ -30,8 +28,4 @@ class Whitespace extends Mustache { array('key with space' => 'G'), ); } - - protected $_partials = array( - 'alphabet' => " * {{.}}\n", - ); -} \ No newline at end of file +} diff --git a/examples/whitespace/partials/alphabet.mustache b/examples/whitespace/partials/alphabet.mustache new file mode 100644 index 0000000..d281c41 --- /dev/null +++ b/examples/whitespace/partials/alphabet.mustache @@ -0,0 +1 @@ + * {{.}} \ No newline at end of file