Fluid gets template APIs: The new f:argument ViewHelper
Have the article read aloud.
Fluid 4.2.0 brings an exciting feature: the <f:argument> ViewHelper takes templates and partials to a new level. We can finally give our templates clear APIs.
Until now, it was sometimes a guessing game: Which variables does this partial need? What type does it expect? What happens if I forget something? The new ViewHelper solves these problems elegantly.
What does f:argument do?
You define directly in the template which variables are required, which types they have and which are optional. Fluid then automatically checks the output: Are the transferred values correct? Is something important missing? If so, there is a clear error message.
This makes templates self-documenting. A glance at the first few lines immediately reveals the complete API - i.e. which "inputs" the template has and what it expects. Perfect for teams or when you look at your own templates again after months.
My first thoughts
I find this very interesting and will certainly test it in practice soon. I see enormous potential, especially for more complex partials that are used in different contexts. Finally an end to "Why doesn't the partial work here?" - discussions.
The official documentation shows all the details, and you can find the technical background in the commit message.
What do you think about it?
Will you use the new ViewHelper?
Do you see any other use cases or potential problems?
Share your thoughts in the comments - I look forward to hearing your experiences and opinions on this exciting update!
BackComments under articles are disabled. If you have a question or addition, please send me an e-mail.
Hi, I'm Wolfgang.
I have been working with TYPO3 since 2006. Not in theory, but in real projects with real deadlines. I've probably had the problems you're having three times already.
At some point, I started putting my knowledge into video courses. Not because I like being in front of the camera, but because I kept hearing the same questions over and over again. There are now hundreds of videos. Every single one was the result of a specific question from a specific project.
What makes me different from a YouTube tutorial: I not only know the solution, but also the context. Why something works. When it doesn't work. And which mistakes you can avoid because I've already made them.
As a member of the TYPO3 Education Committee, I make sure that the certification exams are kept up to date. What is tested there flows directly into my courses.