Skip to content

Commit

Permalink
Update index.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
seb-jean authored Nov 7, 2024
1 parent dd67909 commit f7fcea7
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/Turbo/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,32 +297,35 @@ Minimal layout for Turbo Frames

Since Turbo does not need the content outside of the frame, reducing the amount that is rendered can be a useful optimisation. There are cases where it would be useful for Turbo to have access to items specified in ``head``. To specify the heads, you must then use a minimal layout for frame, rather than no layout. it allows you to set ``meta`` tags while still having a minimal layout.

.. code-block:: html+twig
// src/Controller/TaskController.php
namespace App\Controller;

{% extends '@Turbo/frame.html.twig' %}
// ...

{% block head %}
<meta name="alternative" content="present" />
{% endblock %}
class TaskController extends AbstractController
{
public function markAllAsDone(): Response
{
return $this->renderBlock('task/index.html.twig', 'mark_all_as_done');
}
}

{% block body %}
<turbo-frame id="frame_id">
Content of the Turbo Frame
</turbo-frame>
.. code-block:: html+twig

{# bottom of task/index.html.twig #}
{% block mark_all_as_done %}
<!DOCTYPE html>
<html>
<head>
<meta name="alternative" content="present" />
</head>
<body>
<turbo-frame id="mark-all-as-done">
A placeholder.
</turbo-frame>
</body>
</html>
{% endblock %}

{# renders as: #}
<!DOCTYPE html>
<html>
<head>
<meta name="alternative" content="present" />
</head>
<body>
<turbo-frame id="frame_id">
Content of the Turbo Frame
</turbo-frame>
</body>
</html>

Writing Tests
^^^^^^^^^^^^^
Expand Down

0 comments on commit f7fcea7

Please # to comment.