Convert Fluid Tag Syntax to Inline Automatically
Fluid offers two notations for ViewHelpers: tag syntax and inline. The PhpStorm plugin TYPO3 Fluid Inline Converter turns tag notation into the more compact inline form with a single keystroke, even for nested and chained ViewHelpers.
Fluid offers two notations for the same ViewHelper. The tag syntax
<f:format.bytes>...</f:format.bytes> reads well, but becomes needlessly bulky
for simple output. The inline syntax {value -> f:format.bytes()} turns three
lines into one.
The downside is that converting by hand is tedious and error-prone, since syntax errors are harder to spot.
That is exactly what the PhpStorm plugin TYPO3 Fluid Inline Converter takes care of.
Tag Syntax and Inline Syntax
Both notations produce the same result. Inline is more compact as soon as the ViewHelper only formats a single value and contains no nested markup:
Examples
The same template once in tag syntax and once after conversion. Each line corresponds to its counterpart in the other file:
<!-- before: tag syntax -->
<html data-namespace-typo3-fluid="true">
<f:format.htmlentitiesDecode>{newsItem.title}</f:format.htmlentitiesDecode>
<f:format.bytes decimals="1">{data.item_size}</f:format.bytes>
<f:translate key="author" arguments="{0: newsItem.author}" />
<f:translate key="{f:if(condition: '{count} == 1', then: 'entry', else: 'entries')}" />
<f:be.infobox message="{f:translate(domain: 'indexed_search.messages', key: 'administration.noPageSelected')}" state="{f:constant(name: 'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO')}" />
<f:be.uri route="redirects" parameters="{demand: demand.parameters, page: 987654322}" />
<core:icon identifier="{severityIconMapping.{status.severity.value}}" size="default" />
</html>
<!-- after: inline -->
<html data-namespace-typo3-fluid="true">
{newsItem.title -> f:format.htmlentitiesDecode()}
{data.item_size -> f:format.bytes(decimals: 1)}
{f:translate(arguments: {0:newsItem.author}, key: 'author')}
{f:translate(key: '{f:if(condition: \'{count} == 1\', then: \'entry\', else: \'entries\')}')}
{f:be.infobox(message: '{f:translate(domain:\'indexed_search.messages\', key:\'administration.noPageSelected\')}', state: '{f:constant(name: \'TYPO3\CMS\Core\Type\ContextualFeedbackSeverity::INFO\')}')}
{f:be.uri(route: 'redirects', parameters: {demand: demand.parameters, page: 987654322})}
{core:icon(identifier: '{severityIconMapping.{status.severity.value}}', size: 'default')}
</html>
Usage in PhpStorm
The conversion runs through PhpStorm’s intention actions. Place the cursor
inside the ViewHelper, press Alt+Enter and pick the matching action.
Alternatively the entry is available in the context menu via right-click.
Feedback and reviews on the JetBrains Marketplace are always welcome.