Possible fix for #1 - ability to use partials with an arbitrary (non-Mustache) view class.

This commit is contained in:
Justin Hileman
2010-05-22 18:34:24 -04:00
parent 9f31a821e1
commit eeb5b245d1
4 changed files with 28 additions and 44 deletions
@@ -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