Bug #75315
closedWrong inline array notation in ContainerViewHelper docs
100%
Description
I got this in f:be.container with includeCssFiles= and includeJsFiles= (notation found on https://fluidtypo3.org/viewhelpers/fluid/master/Be/ContainerViewHelper.html @all review Options)
"0: '{f:uri.resource(path:\'Css/Styles.css\')}'" gets outputted as string in the response. Debugging this I found that it gets labeled as a TextNode in Classes/Core/Parser/TemplateParser.php in function textAndShorthandSyntaxHandler(). I got it working with this patch:
} elseif ($context === self::CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS && preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS, $section, $matchedVariables) > 0) {
// We only match arrays if we are INSIDE viewhelper arguments
$this->arrayHandler($state, $matchedVariables['Array']);
}
// Thomas Patch
elseif ($context === self::CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS && preg_match(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS, $section, $matchedVariables) > 0) {
// We only match arrays if we are INSIDE viewhelper arguments
$this->arrayHandler($state, $matchedVariables['ArrayPart']);
}
// END Thomas Patch END
else {
$this->textHandler($state, $section);
}
This works, but I am new to this and have not much more in my templates. As far as I can see, this is not constraint to be.container, so it could squat more bugs. But that, and if my patch is the right direction, is for a more knowledgeable person to decide!
Updated by Markus Klein over 8 years ago
- Status changed from New to Needs Feedback
Seems like the page your referenced contains wrong examples.
array syntax basically follows JSON, so an attribute, which requires an array must look like this:
includeCssFiles="{0: 'file1.css', 1: '{f:uri.resource(path:\'Css/Styles.css\')}'}"
Note the additional set of {}
around the value of the attribute.
Updated by Markus Klein over 8 years ago
An example where the Core is using this: https://github.com/TYPO3/TYPO3.CMS/blob/TYPO3_6-2/typo3/sysext/beuser/Resources/Private/Layouts/Default.html#L1
Moreover, if you write a BE module for CMS 7+, consider using the ModuleTemplate API instead of this old view helper.
Updated by Thomas Noest over 8 years ago
The additional set of {} makes it work. You can close this one.
As for ModuleTemplate, I wouldn't know where to start.
Thanks for your time!
Updated by Markus Klein over 8 years ago
- Status changed from Needs Feedback to Closed
Updated by Thomas Noest over 8 years ago
Opened an issue about the wrong doc at fluidtypo3, where they told me that the doc is generated from fluids own docblock.
And that's right, the wrong declaration is in:
Fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php line 41
Should this go in a new issue, or is this enough?
Updated by Markus Klein over 8 years ago
- Subject changed from Inline array notation not parsed to Wrong inline array notation in ContainerViewHelper docs
- Status changed from Closed to Accepted
Can you push a patch?
Updated by Gerrit Code Review over 8 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47522
Updated by Gerrit Code Review over 8 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47522
Updated by Gerrit Code Review over 8 years ago
Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47527
Updated by Wouter Wolters over 8 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ffc36faa75dc1b5a1ea9bb8c841089d3e21c5a83.