mirror of
https://github.com/smarty-php/smarty.git
synced 2025-07-30 16:07:13 +02:00
fixed sample output of section in the docs and added this example as a unit test
This commit is contained in:
@ -178,14 +178,14 @@ The above example will output:
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
name: Jack Jones<br />
|
name: Jack Jones<br />
|
||||||
home phone: 777-555-5555<br />
|
home: 777-555-5555<br />
|
||||||
cell phone: 888-555-5555<br />
|
cell: 888-555-5555<br />
|
||||||
e-mail: jack@myexample.com
|
e-mail: jack@myexample.com
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
name: Jane Munson<br />
|
name: Jane Munson<br />
|
||||||
home phone: 000-555-5555<br />
|
home: 000-555-5555<br />
|
||||||
cell phone: 123456<br />
|
cell: 123456<br />
|
||||||
e-mail: jane@myexample.com
|
e-mail: jane@myexample.com
|
||||||
</p>
|
</p>
|
||||||
```
|
```
|
||||||
|
@ -148,4 +148,37 @@ class CompileSectionTest extends PHPUnit_Smarty
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNestedArrayAsLoopParameter()
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
['name' => 'John Smith', 'home' => '555-555-5555',
|
||||||
|
'cell' => '666-555-5555', 'email' => 'john@myexample.com'],
|
||||||
|
['name' => 'Jack Jones', 'home' => '777-555-5555',
|
||||||
|
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'],
|
||||||
|
['name' => 'Jane Munson', 'home' => '000-555-5555',
|
||||||
|
'cell' => '123456', 'email' => 'jane@myexample.com']
|
||||||
|
];
|
||||||
|
$this->smarty->assign('contacts',$data);
|
||||||
|
$result = $this->smarty->fetch('string:{section name=customer loop=$contacts}
|
||||||
|
name: {$contacts[customer].name}
|
||||||
|
home: {$contacts[customer].home}
|
||||||
|
cell: {$contacts[customer].cell}
|
||||||
|
e-mail: {$contacts[customer].email}
|
||||||
|
{/section}');
|
||||||
|
$this->assertEquals('name: John Smith
|
||||||
|
home: 555-555-5555
|
||||||
|
cell: 666-555-5555
|
||||||
|
e-mail: john@myexample.com
|
||||||
|
name: Jack Jones
|
||||||
|
home: 777-555-5555
|
||||||
|
cell: 888-555-5555
|
||||||
|
e-mail: jack@myexample.com
|
||||||
|
name: Jane Munson
|
||||||
|
home: 000-555-5555
|
||||||
|
cell: 123456
|
||||||
|
e-mail: jane@myexample.com
|
||||||
|
', $result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user