diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index 7ba4026de2..dad4e6a7b4 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -18,7 +18,6 @@ Behavior Changes being filterable from logging. - ``NumericPaginator::paginate()`` now uses the ``finder`` option even when a ``SelectQuery`` instance is passed to it. - Deprecations ============ @@ -86,8 +85,10 @@ ORM View ---- - - ``FormHelper::deleteLink()`` has been added as convenience wrapper for delete links in - templates using `DELETE` method. +- ``FormHelper::deleteLink()`` has been added as convenience wrapper for delete links in + templates using ``DELETE`` method. +- ``HtmlHelper::importmap()`` was added. This method allows you to define + import maps for your JavaScript files. Error ----- diff --git a/en/views/helpers/html.rst b/en/views/helpers/html.rst index c7485f4c48..f3098598b0 100644 --- a/en/views/helpers/html.rst +++ b/en/views/helpers/html.rst @@ -561,6 +561,66 @@ Once you have buffered javascript, you can output it as you would any other // In your layout echo $this->fetch('script'); +Creating Javascript Importmap +----------------------------- + +.. php:method:: importmap(array $map, array $options = []): string + +Creates an `importmap` script tag for your JavaScript files:: + + // In the head tag of your layout + echo $this->Html->importmap([ + 'jquery' => 'jquery.js', + 'wysiwyg' => '/editor/wysiwyg.js' + ]); + +Will output: + +.. code-block:: html + + + +Generating maps with imports, scopes and integrity:: + + echo $this->Html->importmap([ + 'imports' => [ + 'jquery' => 'jquery-3.7.1.min.js', + 'wysiwyg' => '/editor/wysiwyg.js' + ], + 'scopes' => [ + 'scoped/' => [ + 'foo' => 'inner/foo', + ], + ], + 'integrity' => [ + 'jquery' => 'sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=', + ], + ]); + +Will output: + +.. code-block:: html + + + Creating Nested Lists ---------------------