In a command controller I am using a StandaloneView
to create a plain text file. The (simplified) code I use for that is:
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setFormat('txt');
$view->setTemplatePathAndFilename('EXT:myext/Resources/Private/Templates/test.txt');
$view->assignMultiple([
'test' => 'test&test',
]);
$content = $view->render();
The resulting content if the template is just {test}
is test&test
, which I'd expect for html format, but not for txt. I've tried setting the format to txt
, text
and text/plain
, but that doesn't affect the result. I know I can use <f:format.raw>
, but is there a different way to prevent the HTML characters to be escaped if the format is not html
?
I'm using TYPO3 10.4.20.
You can disable output escaping with:
<!-- Disabling HTML escaping for an entire file -->
{escaping off}
Any variables you render will not need to use f:format.raw
even if they contain special HTML entities. Useful when
you render formats other than HTML; or when you completely
trust (read: escaped before assigning to view) all your
variables that get output.
Use with care - caveat emptor!
( https://werkraum.net/devblog/fluid-tipp-8-html-escaping-deaktivieren/ )