Skip to content

[Map] Rename render_map Twig function ux_map #2073

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

Merged
merged 1 commit into from
Aug 20, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/Map/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

## Unreleased

- Rename `render_map` Twig function `ux_map`
- Deprecate `render_map` Twig function

## 2.19

- Component added
8 changes: 4 additions & 4 deletions src/Map/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ A map is created by calling ``new Map()``. You can configure the center, zoom, a
}
}

To render a map in your Twig template, use the ``render_map`` Twig function, e.g.:
To render a map in your Twig template, use the ``ux_map`` Twig function, e.g.:

.. code-block:: twig

{{ render_map(my_map) }}
{{ ux_map(my_map) }}

{# or with custom attributes #}
{{ render_map(my_map, { style: 'height: 300px' }) }}
{{ ux_map(my_map, { style: 'height: 300px' }) }}

Extend the default behavior
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -207,7 +207,7 @@ Then, you can use this controller in your template:

.. code-block:: twig

{{ render_map(my_map, { 'data-controller': 'mymap', style: 'height: 300px' }) }}
{{ ux_map(my_map, { 'data-controller': 'mymap', style: 'height: 300px' }) }}

Backward Compatibility promise
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Map/src/Bridge/Google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ A common use case is to customize the marker. You can listen to the `ux:map:mark

Assuming you have a map with a custom controller:
```twig
{{ render_map(map, {'data-controller': 'my-map' }) }}
{{ ux_map(map, {'data-controller': 'my-map' }) }}
```

You can create a Stimulus controller to customize the markers before they are created:
Expand Down
2 changes: 1 addition & 1 deletion src/Map/src/Bridge/Leaflet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ A common use case is to customize the marker. You can listen to the `ux:map:mark

Assuming you have a map with a custom controller:
```twig
{{ render_map(map, {'data-controller': 'my-map' }) }}
{{ ux_map(map, {'data-controller': 'my-map' }) }}
```

You can create a Stimulus controller to customize the markers before they are created:
Expand Down
8 changes: 7 additions & 1 deletion src/Map/src/Twig/MapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ final class MapExtension extends AbstractExtension
{
public function getFunctions(): iterable
{
yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]);
yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], [
'is_safe' => ['html'],
'deprecated' => '2.20',
'deprecating_package' => 'symfony/ux-map',
'alternative' => 'ux_map',
]);
yield new TwigFunction('ux_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]);
}
}
2 changes: 1 addition & 1 deletion src/Map/tests/TwigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testRenderMap(): void
$twig = self::getContainer()->get('twig');
$twig->setLoader(new ChainLoader([
new ArrayLoader([
'test' => '{{ render_map(map, attributes) }}',
'test' => '{{ ux_map(map, attributes) }}',
]),
$twig->getLoader(),
]));
Expand Down