Skip to content

Commit

Permalink
[TASK] Document the viewhelper directive
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Jul 21, 2024
1 parent 8fa5e58 commit 2df7dac
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Documentation/WritingReST/Reference/Content/ViewHelper.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
:navigation-title: ViewHelper
.. include:: /Includes.rst.txt
.. _viewhelper:

=============================================
Display Fluid ViewHelpers in ReStructuredText
=============================================

The special `.. typo3:viewhelper::` directive can be used to display the
information about a Fluid ViewHelper, including all arguments.

The information on the available arguments is included from a `.json` file.
See also https://github.com/TYPO3-Documentation/fluid-documentation-generator
on how to generate the input file.

.. warning::
Usage of the viewhelper directive outside of the
:ref:`Fluid ViewHelper Reference <t3viewhelper:start>` is still considered
experimental.

.. _viewhelper-example:

Example: Display a ViewHelper from a JSON include
=================================================

.. code-block:: rst
:caption: Documentation/MyViewHelper.rst
.. typo3:viewhelper:: link.external
:source: /resources/global_viewhelpers_demo.json
.. literalinclude:: _ViewHelper/_global_viewhelpers_demo.json
:language: json
:caption: Documentation/resources/global_viewhelpers_demo.json


.. _viewhelper-properties:

Properties of the `viewhelper` directive
========================================

.. confval-menu::
:display: table
:type:

.. include:: _ViewHelper/_Content.rst.txt
:show-buttons:

.. include:: _ViewHelper/_Source.rst.txt
:show-buttons:

.. include:: _ViewHelper/_SortBy.rst.txt
:show-buttons:

.. include:: _ViewHelper/_NoIndex.rst.txt
:show-buttons:
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. confval:: [content]
:name: directive-viewhelper-content
:type: string

Name of the ViewHelper as used as key in the the JSON include file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. confval:: :noindex:
:name: directive-viewhelper-noindex
:type: bool

If set the ViewHelper will only be displayed but cannot be linked and is not
added to any indexes. This is useful if the same ViewHelper should be
displayed in several places within the same document. In such a case there
would be a clash of identifiers and warnings in the rendering if `:noindex:`
is not set.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. confval:: :sortBy:
:name: directive-viewhelper-sortBy
:type: string
:default: `name`

Ordering of the argument list.

name
Sort the arguments alphabetically by name

json
Sort the arguments in the order they appear in the JSON file.

.. code-block:: rst
.. typo3:viewhelper:: split
:source: resources/global_viewhelpers_demo.json
:sortBy: name
.. typo3:viewhelper:: image
:source: resources/global_viewhelpers_demo.json
:sortBy: json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. confval:: :source:
:name: directive-viewhelper-source
:type: string, local file path, relative or absolute

Path to the source JSON file to be included. Can be relative or absolute.

.. code-block:: rst
.. viewhelper:: my.viewhelper
:source: /some/absolute/path/_includes/_my_viewhelper.json
.. viewhelper:: my.viewhelper
:source: ../_includes/_my_viewhelper.json
The path is calculated starting from the :path:`Documentation` directory.
It is not possible to include files from different locations in an extension.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

{
"namespace": "http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers",
"viewHelpers": {
"split": {
"className": "TYPO3Fluid\\Fluid\\ViewHelpers\\SplitViewHelper",
"...": "..."
},
"link.external":{
"className": "TYPO3\\CMS\\Fluid\\ViewHelpers\\Link\\ExternalViewHelper",
"namespace": "TYPO3\\CMS\\Fluid\\ViewHelpers",
"name": "Link\\ExternalViewHelper",
"tagName": "link.external",
"documentation": "A ViewHelper for creating links to external targets.\n\nExamples\n========\n...",
"xmlNamespace": "http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers",
"docTags": {},
"argumentDefinitions": {
"uri": {
"name": "uri",
"type": "string",
"description": "The URI that will be put in the href attribute of the rendered link tag",
"required": true,
"defaultValue": null,
"escape": null
}
},
"allowsArbitraryArguments": true
},
"...": "..."
}
}

0 comments on commit 2df7dac

Please sign in to comment.