Skip to content

Bug: Not possible manipulate results of renderSection() on View Layouts #3028

Description

@natanfelles

Describe the bug
It is not possible to manipulate the string result of a View Layout $this->renderSection() without using ob_* functions due the void function works with echo and not return.

public function renderSection(string $sectionName)
{
if (! isset($this->sections[$sectionName]))
{
echo '';
return;
}
foreach ($this->sections[$sectionName] as $key => $contents)
{
echo $contents;
unset($this->sections[$sectionName][$key]);
}
}

This example https://codeigniter4.github.io/userguide/outgoing/view_layouts.html#creating-a-layout show a echo but it is not necessary.

CodeIgniter 4 version
4.0.3

Affected module(s)
View Layouts

Expected behavior, and steps to reproduce if appropriate

Expect to can save result of renderSection() in a variable.

Context

  • OS: Ubuntu
  • Web server [PHP built in]
  • PHP version [7.4]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions