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

Explain new twig changes while keeping appropriate warnings #1500

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,36 @@ nav:

In Shopware, we extend Twig's functionality by custom ones. See our own actions below.

::: warning
#### No official support for the twig \{\% use \%\} tag

Try to avoid importing blocks from the core templates with the \{\% use \%\} tag for horizontal reuse in twig. [Twig documentation - use tag](https://twig.symfony.com/doc/3.x/tags/use.html).

The \{\% use \%\} tag does not consider the template inheritance similar to \{\% sw_extends \%\}`.
::: info
Official support for complete Twig multi inheritance using sw_* equivalents available since 6.6.7.0
:::

Furthermore, templates which are imported via \{\% use \%\} are not allowed to have additional twig statements outside of twig blocks. Therefore, changes in core templates which are imported via \{\% use \%\} might break your app or plugin.
::: warning
Templates which are imported via \{\% sw_use \%\} are not allowed to have additional twig statements outside of twig blocks. Therefore, changes in core templates which are imported via \{\% sw_use \%\} might break your app or plugin.
:::

## Functions
## Tags

| Function | Description | Notes |
| :--- | :--- | :--- |
| `sw_extends` | Inherits from another file with support for multi inheritance. The API is the same like in twigs default `extends` | --- |
| `sw_include` | Includes template partials with support for multi inheritance. The API is the same like in twigs default `include` | --- |
| `sw_extends` | Inherits from another file with support for multi inheritance. The API is the same like in Twig's default `extends` | See [Twig 3 documentation for `extends`](https://twig.symfony.com/doc/3.x/tags/extends.html) |
| `sw_include` | Includes template partials with support for multi inheritance. The API is the same like in Twig's default `include` but limited to one file at once | See [Twig 3 documentation for `include`](https://twig.symfony.com/doc/3.x/tags/include.html) |
| `sw_embed` | Includes another file with directly overwriting blocks with support for multi inheritance. The API is the same like in Twig's default `embed` | See [Twig 3 documentation for `embed`](https://twig.symfony.com/doc/3.x/tags/embed.html) |
| `sw_use` | Includes template blocks without rendering them from another file with support for multi inheritance. The API is the same like in Twig's default `use` | See [Twig 3 documentation for `use`](https://twig.symfony.com/doc/3.x/tags/use.html) |
| `sw_import` | Includes all macros from another file with support for multi inheritance. The API is the same like in Twig's default `import` | See [Twig 3 documentation for `import`](https://twig.symfony.com/doc/3.x/tags/import.html) |
| `sw_from` | Includes single macros from another file with support for multi inheritance. The API is the same like in Twig's default `from` | See [Twig 3 documentation for `from`](https://twig.symfony.com/doc/3.x/tags/from.html) |
| `sw_icon` | Displays an icon from a given icon set | See [Add custom icon](../../../guides/plugins/plugins/storefront/add-icons#adding-icon) guide for details. |
| `sw_thumbnails` | Renders a tag with correctly configured “srcset” and “sizes” attributes based on the provided parameters | See [Add thumbnail](../../../guides/plugins/plugins/storefront/use-media-thumbnails) guide for more information. |

## Functions

| Function | Description | Notes |
| :--- | :--- | :--- |
| `config` | Gets a value from the system config (used by plugins and global settings) for the given sales channel | See [Reading the configuration values](../../../guides/plugins/apps/configuration) |
| `theme_config` | Gets a value from the current theme | See [Theme configuration](../../../guides/plugins/themes/theme-configuration) |
| `sw_block` | Renders a block of the same or another file with support for multi inheritance. The is the same like in Twig's default `block` | See [Twig 3 documentation for `block`](https://twig.symfony.com/doc/3.x/functions/block.html) |
| `sw_source` | Prints the content of a template file with support for multi inheritance. The is the same like in Twig's default `source` | See [Twig 3 documentation for `source`](https://twig.symfony.com/doc/3.x/functions/source.html) |
| `sw_include` | Renders the content of another template file with support for multi inheritance. The is the same like in Twig's default `include` and the new `sw_include` tag | See [Twig 3 documentation for `include`](https://twig.symfony.com/doc/3.x/functions/include.html) |

## Filter

Expand Down