Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 11.5] [TASK] Expand section about partials #1992

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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