Skip to content

Commit

Permalink
[TASK] Expand section about partials
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sypets authored and github-actions[bot] committed Jul 21, 2022
1 parent 1d10f9b commit 4979c3f
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 @@ -174,9 +174,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 4979c3f

Please sign in to comment.