Merge branch 'dev' into feature/implicit-iterator

Conflicts:
	Mustache.php
This commit is contained in:
Justin Hileman
2010-07-05 15:55:00 -04:00
20 changed files with 317 additions and 129 deletions
@@ -0,0 +1,24 @@
<?php
class GrandParentContext extends Mustache {
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;
}
}
@@ -0,0 +1,10 @@
{{grand_parent_id}}
{{#parent_contexts}}
{{grand_parent_id}}
{{parent_id}}
{{#child_contexts}}
{{grand_parent_id}}
{{parent_id}}
{{child_id}}
{{/child_contexts}}
{{/parent_contexts}}
@@ -0,0 +1,17 @@
grand_parent1
grand_parent1
parent1
grand_parent1
parent1
parent1-child1
grand_parent1
parent1
parent1-child2
grand_parent1
parent2
grand_parent1
parent2
parent2-child1
grand_parent1
parent2
parent2-child2
@@ -0,0 +1,19 @@
<?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,0 +1,2 @@
Children of {{name}}:
{{>children}}
@@ -0,0 +1,3 @@
Children of ilmich:
federica - 27 - female
marco - 32 - male
@@ -1,5 +1,5 @@
<?php
class PragmaUnescaped extends Mustache {
protected $vs = 'Bear > Shark';
public $vs = 'Bear > Shark';
}
@@ -0,0 +1,8 @@
<?php
class PragmasInPartials extends Mustache {
public $say = '< RAWR!! >';
protected $_partials = array(
'dinosaur' => '{{say}}'
);
}
@@ -0,0 +1,3 @@
{{%UNESCAPED}}
{{say}}
{{>dinosaur}}
@@ -0,0 +1,2 @@
< RAWR!! >
&lt; RAWR!! &gt;
@@ -0,0 +1,16 @@
<?php
class RecursivePartials extends Mustache {
protected $_partials = array(
'child' => " > {{ name }}{{#child}}{{>child}}{{/child}}",
);
public $name = 'George';
public $child = array(
'name' => 'Dan',
'child' => array(
'name' => 'Justin',
'child' => false,
)
);
}
@@ -0,0 +1 @@
{{name}}{{#child}}{{>child}}{{/child}}
@@ -0,0 +1 @@
George > Dan > Justin