Components in non-HTML context
This is not necessarily a bug report. This is just a documentation of the mismatch between my expectations and the reality. Do whatever you want with this information.
What I found
I just tried to use the new components feature in a *.txt file. And I expected the component file EmailSignaturePlain/EmailSignaturePlain.txt with same file extension to be loaded.
My template file
{namespace c=My\Sitepackage\Components\ComponentCollection}<f:spaceless><f:render section="Title" optional="true" />
<f:render section="Main" /></f:spaceless>
<c:emailSignaturePlain />
The error message:
(1/3) #1407060572 TYPO3Fluid\Fluid\Core\Parser\Exception
Fluid parse error in template layout_SystemEmail_txt_ecc46b683b76185a, line 3 at character 2. Error: The ViewHelper "<c:emailSignaturePlain>" could not be resolved. Based on your spelling, the system would load the component template "EmailSignaturePlain/EmailSignaturePlain.html" in "/var/www/html/vendor/my/sitepackage/Resources/Private/Components/", however this file does not exist. (error code 1407060572). Template source chunk: <c:emailSignaturePlain />
What I would expect
Fluid should be able to find component files with the same file extension as the original template file.
To be honest, I do not know, how to handle components that are used in multiple formats (in *.html and *.txt template files) at the same time. Maybe a fallback chain to first try to find the specific one with the same file extension and *.html as fallback.
Fluid should be able to find component files with the same file extension as the original template file.
I tend to agree with that, as this is the same way partials are dealt with if the format isn't specified:
MyTemplate.txt:
<f:render partial="MyPartial" /> <!-- Resolves to MyPartial.txt -->
<f:render partial="MyPartial.txt" /> <!-- Resolves to MyPartial.txt -->
<f:render partial="MyPartial.html" /> <!-- Resolves to MyPartial.html -->
I would say that this is a bug that should be fixed in 4.x. Would you be willing to provide a PR? I think it should be enough to hand over the format in ComponentRenderer to the inner rendering context.
To be honest, I do not know, how to handle components that are used in multiple formats (in *.html and *.txt template files) at the same time. Maybe a fallback chain to first try to find the specific one with the same file extension and *.html as fallback.
Not sure about that either. However, that would be a new feature.
Would you be willing to provide a PR?
Do not expect anything within the next three weeks. 🙂