Skip to content

Commit

Permalink
[TASK] Expand section about partials (#1978)
Browse files Browse the repository at this point in the history
* [TASK] Expand section about partials

Since this part, should replace the page "Moving repeating snippets
to partials" in the Extbase book, it should include an example.

Related: TYPO3-Documentation/TYPO3CMS-Book-ExtbaseFluid#536

* Update Documentation/ApiOverview/Fluid/Introduction.rst

Co-authored-by: Chris Müller <2566282+brotkrueml@users.noreply.github.com>

Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com>
Co-authored-by: Chris Müller <2566282+brotkrueml@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 21, 2022
1 parent cdc1b75 commit 65bae29
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions Documentation/ApiOverview/Fluid/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,35 @@ The template should include the sections which are to be rendered.

*optional*

Partials are a Fluid component. Partials can be used as reusable components from within
a template.
Some parts within different templates might be the same. To not repeat this part
in multiple templates, Fluid offers so-called partials. Partials are small pieces
of Fluid template within a separate file that can be included in multiple templates.

Partials are stored, by convention, within :file:`Resources/Private/Partials/`.

Example partial:

.. code-block:: html
:caption: EXT:my_extension/Resources/Private/Partials/Tags.html

<b>Tags</b>:
<ul>
<f:for each="{tags}" as="tag">
<li>{tag}</li>
</f:for>
</ul>

Example template using the partial:

.. code-block:: html
:caption: EXT:my_extension/Resources/Private/Templates/Show.html

<f:render partial="Tags" arguments="{tags: post.tags}" />

The variable :html:`post.tags` is passed to the partial as variable :html:`tags`.

If ViewHelpers from a different namespace are used in the partial, the namespace
import can be done in the template or the partial.

Example: Using Fluid to create a theme
======================================
Expand Down

0 comments on commit 65bae29

Please sign in to comment.