Recent Improvements in Fluid

Categories: Development, TYPO3 CMS Created by Simon Praetorius
A laptop screen showing a code example. Next to it, a bottle of a black liquid and a bouquet of flowers.
The author's hand holding a bottle of black fluid next to a computer at TYPO3camp München. The computer screen displays some of the new features of Fluid v4. Photo: Mathias Bolt Lesniak (CC BY)
Some of you in the TYPO3 community may have already noticed increased activity around TYPO3’s templating engine, Fluid, in recent months. The Fluid maintainer team has been busy delivering the new major version 4 in time for the feature freeze with TYPO3 13.3. And we made it!

TYPO3 13 is based on Fluid 4. All older TYPO3 versions will stay on Fluid 2. We're skipping Fluid version 3 entirely, as an older development branch originally designated for that version never reached a stable release.

Development Strategy

When we started development on the new major version, we set an important goal for ourselves: to deliver meaningful changes to Fluid without breaking any user-facing API or templates. As a result, we adopted a 3-step deprecation strategy to give Fluid users advance notice of any changes that might affect their code.

  • In recent minor versions of Fluid 2, we introduced soft deprecations (using the @deprecated annotation in DocBlock comments) and provided a detailed changelog.
  • In Fluid 4, we log deprecation notices in addition to the annotations, and provide a separate changelog. Recently deprecated code still works and will not be removed.
  • Only in Fluid 5 will we remove previously deprecated code.

This strategy makes the jump from Fluid 2 to Fluid 4 a straightforward migration for all users.

Backported Features

A benefit of our deprecation strategy is that most new features have been backported to Fluid 2, making them available to older TYPO3 instances. For example:

We’ve also overhauled the ViewHelper reference documentation. It contains more information than before and is still based on the actual ViewHelper code — which guarantees that it’s always up-to-date.

Exclusive Features

For some features, it wasn’t feasible to backport them to older Fluid or TYPO3 versions. These are exclusive to TYPO3 13 and Fluid 4:

  • The <f:comment> ViewHelper now ignores syntax errors, which allows commenting-out invalid Fluid code during development. Finally!
  • true, false and null are now part of the Fluid syntax, which allows using them as variables in templates, like {true}.
  • Tag-based ViewHelpers, such as <f:form.*>, now support HTML5-style boolean attributes by providing a boolean as value: <f:form.textfield readonly=”{isReadonly}” /> will omit the readonly attribute altogether if {isReadonly} is set to false.

Important Changes

Although your Fluid-related code will likely just keep working in TYPO3 13, we encourage TYPO3 users to review the upcoming Fluid changes early, especially:

  • renderStatic() in ViewHelpers and the associated traits have been deprecated. We encourage all users to switch to the non-static render() method as the primary rendering method for all ViewHelpers. renderStatic() will still work in Fluid v4, but won’t be called in Fluid v5.
  • Use the new ViewFactory when creating your own View object in TYPO3 13. Don’t create your own StandaloneView or TemplateView because these are now deprecated.
  • We recommend using the latest Fluid 2 version in your TYPO3 12 or lower projects to take advantage of most new features. This will also simplify your future migration to TYPO3 13 and Fluid 4.

Looking Ahead

We believe that this new major version is a huge step forward for Fluid, as we’ve managed to clean up a lot under the hood. The deprecations will allow us to streamline and simplify even more in the near future, paving the way for powerful new features in the coming years. We are very happy with the progress we have made so far and we hope that you will appreciate the new Fluid features in your TYPO3 projects.

Last but not least we want to give a big shout out to Claus Due,who maintained Fluid before the current team took over. We greatly value his feedback and are grateful for the inspiring ideas he developed with his Fluid 3 prototype. We still have them in the back of our heads and are thinking about the necessary steps to integrate them into Fluid in the future.

Check out the full Fluid 4 release notes.

Additional contributors for this article
  • Proofreader : Felicity Brand
  • Reviewer : Christian Kuhn
  • Reviewer : Stefan Bürk
  • Content Publisher : Mathias Bolt Lesniak