Dot notation with numeric indexes fix.
This commit is contained in:
+1
-1
@@ -773,7 +773,7 @@ class Mustache {
|
|||||||
$first = array_shift($chunks);
|
$first = array_shift($chunks);
|
||||||
|
|
||||||
$ret = $this->_findVariableInContext($first, $this->_context);
|
$ret = $this->_findVariableInContext($first, $this->_context);
|
||||||
while ($next = array_shift($chunks)) {
|
foreach ($chunks as $next) {
|
||||||
// Slice off a chunk of context for dot notation traversal.
|
// Slice off a chunk of context for dot notation traversal.
|
||||||
$c = array($ret);
|
$c = array($ret);
|
||||||
$ret = $this->_findVariableInContext($next, $c);
|
$ret = $this->_findVariableInContext($next, $c);
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ class DotNotation extends Mustache {
|
|||||||
public $person = array(
|
public $person = array(
|
||||||
'name' => array('first' => 'Chris', 'last' => 'Firescythe'),
|
'name' => array('first' => 'Chris', 'last' => 'Firescythe'),
|
||||||
'age' => 24,
|
'age' => 24,
|
||||||
|
'hobbies' => array('Cycling', 'Fishing'),
|
||||||
'hometown' => array(
|
'hometown' => array(
|
||||||
'city' => 'Cincinnati',
|
'city' => 'Cincinnati',
|
||||||
'state' => 'OH',
|
'state' => 'OH',
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public $normal = 'Normal';
|
public $normal = 'Normal';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
* {{person.name.first}} {{person.name.last}}
|
* {{person.name.first}} {{person.name.last}}
|
||||||
* {{person.age}}
|
* {{person.age}}
|
||||||
|
* {{person.hobbies.0}}, {{person.hobbies.1}}
|
||||||
* {{person.hometown.city}}, {{person.hometown.state}}
|
* {{person.hometown.city}}, {{person.hometown.state}}
|
||||||
* {{normal}}
|
* {{normal}}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
* Chris Firescythe
|
* Chris Firescythe
|
||||||
* 24
|
* 24
|
||||||
|
* Cycling, Fishing
|
||||||
* Cincinnati, OH
|
* Cincinnati, OH
|
||||||
* Normal
|
* Normal
|
||||||
|
|||||||
Reference in New Issue
Block a user