Skip to content

Commit 4bb9ee7

Browse files
committed
feature #2073 [Map] Rename render_map Twig function ux_map (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [Map] Rename `render_map` Twig function `ux_map` | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | Fix #... | License | MIT ### Context As we recently saw with the `cva` function and forgot to do here: we should prefix every new component / package / Twig function or filter with `ux` to avoid conflict with existing codebases... and with future symfony or twig new methods. ### This PR This PR renames `render_map` (inspired by charts hjs "render_chart") into `ux_map` (in line with what we did for UX Icons) ```diff <div> - {{ render_map(map) }} + {{ ux_map(map) }} </div> ``` ### Next We can keep the render_map for _some_ time, but it's marked as deprecated right now, and i think this is the good moment to update documentation, to limit future BC break / changes for users (even if we are in experimental) ### Website Once this once is merged, the website page will need to be updated Commits ------- b539c1a Rename `render_map` Twig function `ux_map`
2 parents 2ded754 + b539c1a commit 4bb9ee7

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

src/Map/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22

33
## Unreleased
44

5+
- Rename `render_map` Twig function `ux_map`
6+
- Deprecate `render_map` Twig function
7+
8+
## 2.19
9+
510
- Component added

src/Map/doc/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ A map is created by calling ``new Map()``. You can configure the center, zoom, a
120120
}
121121
}
122122

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

125125
.. code-block:: twig
126126
127-
{{ render_map(my_map) }}
127+
{{ ux_map(my_map) }}
128128
129129
{# or with custom attributes #}
130-
{{ render_map(my_map, { style: 'height: 300px' }) }}
130+
{{ ux_map(my_map, { style: 'height: 300px' }) }}
131131
132132
Extend the default behavior
133133
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -207,7 +207,7 @@ Then, you can use this controller in your template:
207207

208208
.. code-block:: twig
209209
210-
{{ render_map(my_map, { 'data-controller': 'mymap', style: 'height: 300px' }) }}
210+
{{ ux_map(my_map, { 'data-controller': 'mymap', style: 'height: 300px' }) }}
211211
212212
Backward Compatibility promise
213213
------------------------------

src/Map/src/Bridge/Google/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ A common use case is to customize the marker. You can listen to the `ux:map:mark
9090

9191
Assuming you have a map with a custom controller:
9292
```twig
93-
{{ render_map(map, {'data-controller': 'my-map' }) }}
93+
{{ ux_map(map, {'data-controller': 'my-map' }) }}
9494
```
9595

9696
You can create a Stimulus controller to customize the markers before they are created:

src/Map/src/Bridge/Leaflet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ A common use case is to customize the marker. You can listen to the `ux:map:mark
4747

4848
Assuming you have a map with a custom controller:
4949
```twig
50-
{{ render_map(map, {'data-controller': 'my-map' }) }}
50+
{{ ux_map(map, {'data-controller': 'my-map' }) }}
5151
```
5252

5353
You can create a Stimulus controller to customize the markers before they are created:

src/Map/src/Twig/MapExtension.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ final class MapExtension extends AbstractExtension
2424
{
2525
public function getFunctions(): iterable
2626
{
27-
yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]);
27+
yield new TwigFunction('render_map', [Renderers::class, 'renderMap'], [
28+
'is_safe' => ['html'],
29+
'deprecated' => '2.20',
30+
'deprecating_package' => 'symfony/ux-map',
31+
'alternative' => 'ux_map',
32+
]);
33+
yield new TwigFunction('ux_map', [Renderers::class, 'renderMap'], ['is_safe' => ['html']]);
2834
}
2935
}

src/Map/tests/TwigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testRenderMap(): void
4444
$twig = self::getContainer()->get('twig');
4545
$twig->setLoader(new ChainLoader([
4646
new ArrayLoader([
47-
'test' => '{{ render_map(map, attributes) }}',
47+
'test' => '{{ ux_map(map, attributes) }}',
4848
]),
4949
$twig->getLoader(),
5050
]));

0 commit comments

Comments
 (0)