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

Rendering of empty template file returns null #407

Open
s-diez opened this issue Sep 28, 2018 · 2 comments
Open

Rendering of empty template file returns null #407

s-diez opened this issue Sep 28, 2018 · 2 comments
Labels

Comments

@s-diez
Copy link

s-diez commented Sep 28, 2018

If you render empty template files for example through TYPO3\CMS\Fluid\View\StandaloneView you get null as the return. This is kind of unexpected as the documentation of TYPO3Fluid\Fluid\View\AbstractTemplateView::render() has a return of type string. Furthermore if you do not expect this and try to cache the output in TYPO3\CMS\Core\Cache\Frontend\StringFrontend it will never be cached, as null can not be cached by it.

Especially because of the documentation and the interaction with the cache, I would consider this a bug.

@derhansen
Copy link
Member

I would also say this is a bug. At least it leads to problem when you with with strict types and expect render() to return a string.

See: in2code-de/powermail#641

@NamelessCoder
Copy link
Member

Agreed, but I think the right solution is to correct the return type annotation to string|null - it is nice to be able to tell if the template truly didn't cause any output at all, versus if it did render a template but the result was an empty string. Among other things this is used in f:render to determine if the default/fallback representation should be returned if for example a non-existing partial or section was rendered but optional=true was requested.

@ohader ohader added the bug label Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants