Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix incorrect sample code in view_parser #7103

Merged
merged 4 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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