Sfoglia il codice sorgente

Update `examples` for v2.0

Justin Hileman 13 anni fa
parent
commit
1d116d1b77
40 ha cambiato i file con 69 aggiunte e 132 eliminazioni
  1. 3 3
      examples/child_context/ChildContext.php
  2. 2 2
      examples/comments/Comments.php
  3. 2 2
      examples/complex/complex.php
  4. 2 2
      examples/delimiters/Delimiters.php
  5. 3 9
      examples/dot_notation/DotNotation.php
  6. 1 2
      examples/dot_notation/dot_notation.mustache
  7. 1 2
      examples/dot_notation/dot_notation.txt
  8. 2 2
      examples/double_section/DoubleSection.php
  9. 2 2
      examples/escaped/Escaped.php
  10. 5 7
      examples/grand_parent_context/GrandParentContext.php
  11. 4 4
      examples/i18n/I18n.php
  12. 3 3
      examples/implicit_iterator/ImplicitIterator.php
  13. 2 2
      examples/inverted_double_section/InvertedDoubleSection.php
  14. 2 2
      examples/inverted_section/InvertedSection.php
  15. 6 2
      examples/inverted_section/inverted_section.mustache
  16. 1 1
      examples/inverted_section/inverted_section.txt
  17. 2 6
      examples/partials/Partials.php
  18. 2 0
      examples/partials/partials/children.mustache
  19. 0 19
      examples/partials_with_view_class/PartialsWithViewClass.php
  20. 0 2
      examples/partials_with_view_class/partials_with_view_class.mustache
  21. 0 3
      examples/partials_with_view_class/partials_with_view_class.txt
  22. 0 5
      examples/pragma_unescaped/PragmaUnescaped.php
  23. 0 3
      examples/pragma_unescaped/pragma_unescaped.mustache
  24. 0 2
      examples/pragma_unescaped/pragma_unescaped.txt
  25. 0 8
      examples/pragmas_in_partials/PragmasInPartials.php
  26. 0 3
      examples/pragmas_in_partials/pragmas_in_partials.mustache
  27. 0 2
      examples/pragmas_in_partials/pragmas_in_partials.txt
  28. 2 6
      examples/recursive_partials/RecursivePartials.php
  29. 1 0
      examples/recursive_partials/partials/child.mustache
  30. 2 2
      examples/section_iterator_objects/SectionIteratorObjects.php
  31. 2 2
      examples/section_magic_objects/SectionMagicObjects.php
  32. 2 2
      examples/section_objects/SectionObjects.php
  33. 2 2
      examples/sections/Sections.php
  34. 2 2
      examples/sections_nested/SectionsNested.php
  35. 2 2
      examples/simple/Simple.php
  36. 2 2
      examples/unescaped/Unescaped.php
  37. 2 2
      examples/utf8/UTF8.php
  38. 2 2
      examples/utf8_unescaped/UTF8Unescaped.php
  39. 2 8
      examples/whitespace/Whitespace.php
  40. 1 0
      examples/whitespace/partials/alphabet.mustache

+ 3 - 3
examples/child_context/ChildContext.php

@@ -1,13 +1,13 @@
 <?php
 
-class ChildContext extends Mustache {
+class ChildContext {
 	public $parent = array(
 		'child' => 'child works',
 	);
-	
+
 	public $grandparent = array(
 		'parent' => array(
 			'child' => 'grandchild works',
 		),
 	);
-}
+}

+ 2 - 2
examples/comments/Comments.php

@@ -1,7 +1,7 @@
 <?php
 
-class Comments extends Mustache {
+class Comments {
 	public function title() {
 		return 'A Comedy of Errors';
 	}
-}
+}

+ 2 - 2
examples/complex/complex.php

@@ -1,6 +1,6 @@
 <?php
 
-class Complex extends Mustache {
+class Complex {
 	public $header = 'Colors';
 
 	public $item = array(
@@ -16,4 +16,4 @@ class Complex extends Mustache {
 	public function isEmpty() {
 		return count($this->item) === 0;
 	}
-}
+}

+ 2 - 2
examples/delimiters/Delimiters.php

@@ -1,6 +1,6 @@
 <?php
 
-class Delimiters extends Mustache {
+class Delimiters {
 	public $start = "It worked the first time.";
 
 	public function middle() {
@@ -11,4 +11,4 @@ class Delimiters extends Mustache {
 	}
 
 	public $final = "Then, surprisingly, it worked the final time.";
-}
+}

+ 3 - 9
examples/dot_notation/DotNotation.php

@@ -1,19 +1,13 @@
 <?php
 
-/**
- * DotNotation example class. Uses DOT_NOTATION pragma.
- *
- * @extends Mustache
- */
-class DotNotation extends Mustache {
+class DotNotation {
 	public $person = array(
 		'name' => array('first' => 'Chris', 'last' => 'Firescythe'),
 		'age' => 24,
-		'hobbies' => array('Cycling', 'Fishing'),
 		'hometown' => array(
-			'city' => 'Cincinnati',
+			'city'  => 'Cincinnati',
 			'state' => 'OH',
-		),
+		)
 	);
 
 	public $normal = 'Normal';

+ 1 - 2
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}}

+ 1 - 2
examples/dot_notation/dot_notation.txt

@@ -1,5 +1,4 @@
 * Chris Firescythe
 * 24
-* Cycling, Fishing
 * Cincinnati, OH
-* Normal
+* Normal

+ 2 - 2
examples/double_section/DoubleSection.php

@@ -1,9 +1,9 @@
 <?php
 
-class DoubleSection extends Mustache {
+class DoubleSection {
 	public function t() {
 		return true;
 	}
 
 	public $two = "second";
-}
+}

+ 2 - 2
examples/escaped/Escaped.php

@@ -1,5 +1,5 @@
 <?php
 
-class Escaped extends Mustache {
+class Escaped {
 	public $title = '"Bear" > "Shark"';
-}
+}

+ 5 - 7
examples/grand_parent_context/GrandParentContext.php

@@ -1,24 +1,22 @@
 <?php
 
-class GrandParentContext extends Mustache {
+class GrandParentContext {
 	public $grand_parent_id = 'grand_parent1';
 	public $parent_contexts = array();
-	
+
 	public function __construct() {
-		parent::__construct();
-		
 		$this->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;
 	}
-}
+}

+ 4 - 4
examples/i18n/I18n.php

@@ -1,6 +1,6 @@
 <?php
 
-class I18n extends Mustache {
+class I18n {
 
     // Variable to be interpolated
     public $name = 'Bob';
@@ -9,12 +9,12 @@ class I18n extends Mustache {
     public $__ = array(__CLASS__, '__trans');
 
     // A *very* small i18n dictionary :)
-    private $dictionary = array(
+    private static $dictionary = array(
         'Hello.' => '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;
     }
-}
+}

+ 3 - 3
examples/implicit_iterator/ImplicitIterator.php

@@ -1,5 +1,5 @@
 <?php
 
-class ImplicitIterator extends Mustache {
-	protected $data = array('Donkey Kong', 'Luigi', 'Mario', 'Peach', 'Yoshi');
-}
+class ImplicitIterator {
+	public $data = array('Donkey Kong', 'Luigi', 'Mario', 'Peach', 'Yoshi');
+}

+ 2 - 2
examples/inverted_double_section/InvertedDoubleSection.php

@@ -1,6 +1,6 @@
 <?php
 
-class InvertedDoubleSection extends Mustache {
+class InvertedDoubleSection {
 	public $t = false;
 	public $two = 'second';
-}
+}

+ 2 - 2
examples/inverted_section/InvertedSection.php

@@ -1,5 +1,5 @@
 <?php
 
-class InvertedSection extends Mustache {
+class InvertedSection {
 	public $repo = array();
-}
+}

+ 6 - 2
examples/inverted_section/inverted_section.mustache

@@ -1,2 +1,6 @@
-{{#repo}}<b>{{name}}</b>{{/repo}}
-{{^repo}}No repos :({{/repo}}
+{{#repo}}
+    <b>{{name}}</b>
+{{/repo}}
+{{^repo}}
+    No repos :(
+{{/repo}}

+ 1 - 1
examples/inverted_section/inverted_section.txt

@@ -1 +1 @@
-No repos :(
+    No repos :(

+ 2 - 6
examples/partials/Partials.php

@@ -1,13 +1,9 @@
 <?php
 
-class Partials extends Mustache {
+class Partials {
 	public $name = 'ilmich';
 	public $data = array(
 		array('name' => 'federica', 'age' => 27, 'gender' => 'female'),
 		array('name' => 'marco', 'age' => 32, 'gender' => 'male'),
 	);
-
-	protected $_partials = array(
-		'children' => "{{#data}}{{name}} - {{age}} - {{gender}}\n{{/data}}",
-	);
-}
+}

+ 2 - 0
examples/partials/partials/children.mustache

@@ -0,0 +1,2 @@
+{{#data}}{{name}} - {{age}} - {{gender}}
+{{/data}}

+ 0 - 19
examples/partials_with_view_class/PartialsWithViewClass.php

@@ -1,19 +0,0 @@
-<?php
-
-class PartialsWithViewClass extends Mustache {
-	public function __construct($template = null, $view = null, $partials = null) {
-		// Use an object of an arbitrary class as a View for this Mustache instance:
-		$view = new StdClass();
-		$view->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);
-	}
-}

+ 0 - 2
examples/partials_with_view_class/partials_with_view_class.mustache

@@ -1,2 +0,0 @@
-Children of {{name}}:
-{{>children}}

+ 0 - 3
examples/partials_with_view_class/partials_with_view_class.txt

@@ -1,3 +0,0 @@
-Children of ilmich:
-federica - 27 - female
-marco - 32 - male

+ 0 - 5
examples/pragma_unescaped/PragmaUnescaped.php

@@ -1,5 +0,0 @@
-<?php
-
-class PragmaUnescaped extends Mustache {
-	public $vs = 'Bear > Shark';
-}

+ 0 - 3
examples/pragma_unescaped/pragma_unescaped.mustache

@@ -1,3 +0,0 @@
-{{%UNESCAPED}}
-{{vs}}
-{{{vs}}}

+ 0 - 2
examples/pragma_unescaped/pragma_unescaped.txt

@@ -1,2 +0,0 @@
-Bear > Shark
-Bear &gt; Shark

+ 0 - 8
examples/pragmas_in_partials/PragmasInPartials.php

@@ -1,8 +0,0 @@
-<?php
-
-class PragmasInPartials extends Mustache {
-	public $say = '< RAWR!! >';
-	protected $_partials = array(
-		'dinosaur' => '{{say}}'
-	);
-}

+ 0 - 3
examples/pragmas_in_partials/pragmas_in_partials.mustache

@@ -1,3 +0,0 @@
-{{%UNESCAPED}}
-{{say}}
-{{>dinosaur}}

+ 0 - 2
examples/pragmas_in_partials/pragmas_in_partials.txt

@@ -1,2 +0,0 @@
-< RAWR!! >
-&lt; RAWR!! &gt;

+ 2 - 6
examples/recursive_partials/RecursivePartials.php

@@ -1,10 +1,6 @@
 <?php
 
-class RecursivePartials extends Mustache {
-	protected $_partials = array(
-		'child' => " > {{ name }}{{#child}}{{>child}}{{/child}}",
-	);
-
+class RecursivePartials {
 	public $name  = 'George';
 	public $child = array(
 		'name'  => 'Dan',
@@ -13,4 +9,4 @@ class RecursivePartials extends Mustache {
 			'child' => false,
 		)
 	);
-}
+}

+ 1 - 0
examples/recursive_partials/partials/child.mustache

@@ -0,0 +1 @@
+ > {{ name }}{{#child}}{{>child}}{{/child}}

+ 2 - 2
examples/section_iterator_objects/SectionIteratorObjects.php

@@ -1,6 +1,6 @@
 <?php
 
-class SectionIteratorObjects extends Mustache {
+class SectionIteratorObjects {
 	public $start = "It worked the first time.";
 
 	protected $_data = array(
@@ -13,4 +13,4 @@ class SectionIteratorObjects extends Mustache {
 	}
 
 	public $final = "Then, surprisingly, it worked the final time.";
-}
+}

+ 2 - 2
examples/section_magic_objects/SectionMagicObjects.php

@@ -1,6 +1,6 @@
 <?php
 
-class SectionMagicObjects extends Mustache {
+class SectionMagicObjects {
 	public $start = "It worked the first time.";
 
 	public function middle() {
@@ -23,4 +23,4 @@ class MagicObject {
 	public function __isset($key) {
 		return isset($this->_data[$key]);
 	}
-}
+}

+ 2 - 2
examples/section_objects/SectionObjects.php

@@ -1,6 +1,6 @@
 <?php
 
-class SectionObjects extends Mustache {
+class SectionObjects {
 	public $start = "It worked the first time.";
 
 	public function middle() {
@@ -13,4 +13,4 @@ class SectionObjects extends Mustache {
 class SectionObject {
 	public $foo = 'And it worked the second time.';
 	public $bar = 'As well as the third.';
-}
+}

+ 2 - 2
examples/sections/Sections.php

@@ -1,6 +1,6 @@
 <?php
 
-class Sections extends Mustache {
+class Sections {
 	public $start = "It worked the first time.";
 
 	public function middle() {
@@ -11,4 +11,4 @@ class Sections extends Mustache {
 	}
 
 	public $final = "Then, surprisingly, it worked the final time.";
-}
+}

+ 2 - 2
examples/sections_nested/SectionsNested.php

@@ -1,6 +1,6 @@
 <?php
 
-class SectionsNested extends Mustache {
+class SectionsNested {
 	public $name = 'Little Mac';
 
 	public function enemies() {
@@ -30,4 +30,4 @@ class SectionsNested extends Mustache {
 			),
 		);
 	}
-}
+}

+ 2 - 2
examples/simple/Simple.php

@@ -1,6 +1,6 @@
 <?php
 
-class Simple extends Mustache {
+class Simple {
 	public $name = "Chris";
 	public $value = 10000;
 
@@ -9,4 +9,4 @@ class Simple extends Mustache {
 	}
 
 	public $in_ca = true;
-};
+};

+ 2 - 2
examples/unescaped/Unescaped.php

@@ -1,5 +1,5 @@
 <?php
 
-class Unescaped extends Mustache {
+class Unescaped {
 	public $title = "Bear > Shark";
-}
+}

+ 2 - 2
examples/utf8/UTF8.php

@@ -1,5 +1,5 @@
 <?php
 
-class UTF8Unescaped extends Mustache {
+class UTF8 {
 	public $test = '中文又来啦';
-}
+}

+ 2 - 2
examples/utf8_unescaped/UTF8Unescaped.php

@@ -1,5 +1,5 @@
 <?php
 
-class UTF8 extends Mustache {
+class UTF8Unescaped {
 	public $test = '中文又来啦';
-}
+}

+ 2 - 8
examples/whitespace/Whitespace.php

@@ -7,10 +7,8 @@
  * tags should strip leading and trailing whitespace in key names.
  *
  * `{{> 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",
-	);
-}
+}

+ 1 - 0
examples/whitespace/partials/alphabet.mustache

@@ -0,0 +1 @@
+ * {{.}}