Browse Source

Clean-up migration guide

3.1.x
Chi 4 years ago
parent
commit
6b71d8e16d
  1. 18
      docs/migration-to-3.x.md

18
docs/migration-to-3.x.md

@ -1,10 +1,16 @@
# Migrating to Twig Tweak 3.x
Twig Tweak 3.x branch is mainly API compatible with 2.x
Below are known BC breaks that may require updating your Twig templates.
## Dependencies
Twig Tweak 3.x requires Drupal 9, Twig 2 and PHP 7.3.
## Rendering entities
Entity ID parameter in `drupal_entity()` and `drupal_field()` functions is now mandatory. Previously it was possible to load entities from current route by omitting entity ID parameter. However, that was making Twig templates coupled with routes and could cause caching issues.
Entity ID parameter in `drupal_entity()` and `drupal_field()` functions is now
mandatory. Previously it was possible to load entities from current route by
omitting entity ID parameter. However, that was making Twig templates coupled
with routes and could cause caching issues.
Before:
```twig
@ -16,8 +22,8 @@ After:
{{ drupal_entity('node', node.id, 'teaser') }}
```
In case a template does not contain a variable with entity object you may prepare in a preprocess hook.
In case a template does not contain a variable with entity object you may
prepare it in a preprocess hook.
```php
/**
* Implements hook_preprocess_page().
@ -28,7 +34,8 @@ function preprocess_page(array &$variables): void {
```
## Rendering blocks
`drupal_block()` now moves attributes provided by block plugin to the outer element. This may break some CSS rules.
`drupal_block()` now moves attributes provided by block plugin to the outer
element. This may break some CSS rules.
Before:
```HTML
@ -45,6 +52,3 @@ After:
```
See https://www.drupal.org/node/3068078 for details.
## Documentation
Cheat Sheet page has been moved to docs/cheat-sheet.md file shipped with the module. This allows to keep documentation in sync with project releases.

Loading…
Cancel
Save