▸ renderStatic()
First of all, renderStatic()
is a static PHP method. This means, you do not have access to instance attributes, such as $this->tag
, which is for example required when your ViewHelper class is a subclass of AbstractTagBasedViewHelper
.
Another drawback of renderStatic()
is that you can not access child nodes. A child node is for example <f:then>
in the following example:
<f:if condition="{variable}">
<f:then>
...
</f:then>
</f:if>
Having said that, renderStatic()
features the best performance, because it is called from within compiled Fluid. Therefore, this method should be used if possible.
▸ render()
Under certain circumstances, this method is the better choice or has to be used for a specific use case (see explanations above). The logic implemented in a render()
method is not compiled, which has an impact on output that is cached.
The downside of render()
is its performance.
▸ Summary / Additional Notes
- Use
renderStatic()
, if you can (performance).
- Use
render()
, if you implement an TagBased-ViewHelper (subclass of
TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper
).
- Use
render()
, if you need to read child nodes.
- Review the ViewHelpers that are shipped with Fluid (e.g. TYPO3 v9 LTS) as examples.
(see: typo3/sysext/fluid/Classes/ViewHelpers/*
) [GitHub]