Skip to content

Commit

Permalink
Merge pull request #7103 from kenjis/fix-docs-view_parser-sample
Browse files Browse the repository at this point in the history
docs: fix incorrect sample code in view_parser
  • Loading branch information
kenjis authored Jan 17, 2023
2 parents c63f4d1 + 05fbd3f commit 7dc9a5e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
8 changes: 4 additions & 4 deletions user_guide_src/source/outgoing/view_parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,21 @@ an associative array of values, like a record from a database:

.. literalinclude:: view_parser/008.php

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

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

<h1>{blog_title} - {blog_heading}</h1>
{blog_entry}
{blog_entries}
<div>
<h2>{title}</h2>
<p>{body}</p>
</div>
{/blog_entry}
{/blog_entries}

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

Comments
Expand Down
8 changes: 5 additions & 3 deletions user_guide_src/source/outgoing/view_parser/008.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
$data = [
'blog_title' => 'My Blog Title',
'blog_heading' => 'My Blog Heading',
'blog_entry' => [
'title' => 'Title 1',
'body' => 'Body 1',
'blog_entries' => [
[
'title' => 'Title 1',
'body' => 'Body 1',
],
],
];

Expand Down
8 changes: 5 additions & 3 deletions user_guide_src/source/outgoing/view_parser/009.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

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

$data = [
'name' => 'George',
'location' => ['city' => 'Red City', 'planet' => 'Mars'],
'name' => 'George',
'locations' => [
['city' => 'Red City', 'planet' => 'Mars'],
],
];

return $parser->setData($data)->renderString($template);
Expand Down
8 changes: 5 additions & 3 deletions user_guide_src/source/outgoing/view_parser/010.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

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

$data = [
'name' => 'George',
'location' => ['city' => 'Red City', 'planet' => 'Mars'],
'name' => 'George',
'locations' => [
['city' => 'Red City', 'planet' => 'Mars'],
],
];

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

0 comments on commit 7dc9a5e

Please sign in to comment.