Fix for #1 - incorrect context for partials.
Partials now receive a flattened version of the parent context, including a cloned Mustache instance (if the root context is a Mustache instance). There may be issues with cloning, for example: if a pragma is enabled in the parent template, partials might also inherit the pragma. Added (basic) test case for partials.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Partials extends Mustache {
|
||||
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}}",
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Children of {{name}}:
|
||||
{{>children}}
|
||||
@@ -0,0 +1,3 @@
|
||||
Children of ilmich:
|
||||
federica - 27 - female
|
||||
marco - 32 - male
|
||||
Reference in New Issue
Block a user