Issue Bug Closed

#60338Changing view format does not affect partial format

Mathias Brodala 07/15/14, 15:35 updated 10/02/18, 11:52

Description

When using one view object to render a template in different formats (e.g. email in text and HTML), the template respects the requested format. However, partials are always rendered in the first rendered format. Example:

Content of templates/partials:

Content of Foo.txt:

Hello
<f:render partial="Bar"/>

Content of Partials/Bar.txt:

World

Content of Foo.html:

<p>Text</p>
<f:render partial="Bar"/>

Content of Partials/Bar.html:

<p>World</p>

1st invocation:

// Let $view be an instance of \TYPO3\CMS\Fluid\View\TemplateView
$view->setFormat('txt');
$view->render('Foo');

Result:

Hello
World

2nd invocation:

// $view is the same instance as above
$view->setFormat('html');
$view->render('Foo');

Result:

<p>Hello</p>
World

As you can see, the 2nd output was rendered using the txt-Partial.

This is due to the local partial identifier cache in AbstractTemplateView which only considers the partial name, not the current request format. If that one is incorporated, separate cache entries for each partial formats are created.

Reviews 2