Skip to content

Commit

Permalink
[TASK] Add ViewHelpers to Fluid syntax
Browse files Browse the repository at this point in the history
Part of the text has been reused from the Extbase book.

In subsequent patches, more content will be migrated
from the Extbase book to TYPO3 Explained.

Related: TYPO3-Documentation/TYPO3CMS-Book-ExtbaseFluid#536
  • Loading branch information
sypets committed Jul 12, 2022
1 parent 0074b9c commit 5f539df
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions Documentation/ApiOverview/Fluid/Syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,56 @@ It is possible to access array or object values by a dynamic index:

myArray.{myIndex}

ViewHelper attributes
=====================
ViewHelpers
===========

ViewHelpers are special tags in the template which provide more complex
functionality such as loops or generating links.

The functionality of the ViewHelper is implemented in PHP, every ViewHelper has
its own PHP class.

Within Fluid, the ViewHelper is used as a special HTML element with a namespace
prefix, for example the namespace prefix "f" is used for ViewHelpers from the
Fluid namespace:

.. code-block:: html
:caption: Fluid example with for ViewHelper

<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<f:for each="{results}" as="result">
<li>{result.title}</li>
</f:for>
</html>

The "f" namespace is already defined, but can be explicitly specified to
improve IDE autocompletion.

If the attribute :html:`data-namespace-typo3-fluid="true"` is specified on the
:html:`html` element, the HTML element itself won’t be rendered
This is useful for various IDEs and HTML auto-completion.

.. code-block:: html
:caption: Fluid example with custom ViewHelper "custom" in namespace "my"

<html
xmlns:my="http://typo3.org/ns/Myvendr/MyExtension/ViewHelpers"
data-namespace-typo3-fluid="true"
>
<my:custom argument1="something"/>
</html>

See the :doc:`Fluid Viewhelper Reference <t3viewhelper:Index>` for a complete
list of all available ViewHelpers.

Viewhelper attributes
---------------------

Simple
------
~~~~~~

Variables can be inserted into ViewHelper attributes by putting them in
curly braces:
Expand Down

0 comments on commit 5f539df

Please sign in to comment.