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

[Turbo] Include minimal layout for Turbo Frames #2318

Open
wants to merge 10 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/Turbo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2.22.0

- Include minimal layout for Turbo Frames
- Add `<twig:Turbo:Stream>` component
- Add `<twig:Turbo:Frame>` component

Expand Down
41 changes: 41 additions & 0 deletions src/Turbo/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,47 @@
A placeholder.
</turbo-frame>

Minimal layout for Turbo Frames
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. versionadded:: 2.22

The minimal layout for Turbo Frames was added in Turbo 2.22.

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:: php

Check failure on line 300 in src/Turbo/doc/index.rst

View workflow job for this annotation

GitHub Actions / DOCtor-RST

Please do not use ".. code-block:: php", use "::" instead.

// src/Controller/TaskController.php
namespace App\Controller;

// ...

class TaskController extends AbstractController
{
public function markAllAsDone(): Response
{
return $this->renderBlock('task/index.html.twig', 'mark_all_as_done');
}
}

.. 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 %}

Writing Tests
^^^^^^^^^^^^^

Expand Down