Skip to content

Commit 7dc9a5e

Browse files
authored
Merge pull request #7103 from kenjis/fix-docs-view_parser-sample
docs: fix incorrect sample code in view_parser
2 parents c63f4d1 + 05fbd3f commit 7dc9a5e

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

user_guide_src/source/outgoing/view_parser.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,21 @@ an associative array of values, like a record from a database:
200200

201201
.. literalinclude:: view_parser/008.php
202202

203-
The value for the pseudo-variable ``blog_entry`` is an associative
203+
The value for the pseudo-variable ``blog_entries`` is an associative
204204
array. The key/value pairs defined inside it will be exposed inside
205205
the variable pair loop for that variable.
206206

207207
A **blog_template.php** that might work for the above::
208208

209209
<h1>{blog_title} - {blog_heading}</h1>
210-
{blog_entry}
210+
{blog_entries}
211211
<div>
212212
<h2>{title}</h2>
213213
<p>{body}</p>
214214
</div>
215-
{/blog_entry}
215+
{/blog_entries}
216216

217-
If you would like the other pseudo-variables accessible inside the ``blog_entry``
217+
If you would like the other pseudo-variables accessible inside the ``blog_entries``
218218
scope, then make sure that the ``cascadeData`` option is set to true.
219219

220220
Comments

user_guide_src/source/outgoing/view_parser/008.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
$data = [
44
'blog_title' => 'My Blog Title',
55
'blog_heading' => 'My Blog Heading',
6-
'blog_entry' => [
7-
'title' => 'Title 1',
8-
'body' => 'Body 1',
6+
'blog_entries' => [
7+
[
8+
'title' => 'Title 1',
9+
'body' => 'Body 1',
10+
],
911
],
1012
];
1113

user_guide_src/source/outgoing/view_parser/009.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3-
$template = '{name} lives in {location}{city} on {planet}{/location}.';
3+
$template = '{name} lives in {locations}{city} on {planet}{/locations}.';
44

55
$data = [
6-
'name' => 'George',
7-
'location' => ['city' => 'Red City', 'planet' => 'Mars'],
6+
'name' => 'George',
7+
'locations' => [
8+
['city' => 'Red City', 'planet' => 'Mars'],
9+
],
810
];
911

1012
return $parser->setData($data)->renderString($template);

user_guide_src/source/outgoing/view_parser/010.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3-
$template = '{location}{name} lives in {city} on {planet}{/location}.';
3+
$template = '{locations}{name} lives in {city} on {planet}{/locations}.';
44

55
$data = [
6-
'name' => 'George',
7-
'location' => ['city' => 'Red City', 'planet' => 'Mars'],
6+
'name' => 'George',
7+
'locations' => [
8+
['city' => 'Red City', 'planet' => 'Mars'],
9+
],
810
];
911

1012
return $parser->setData($data)->renderString($template, ['cascadeData' => false]);

0 commit comments

Comments
 (0)