@@ -561,6 +561,66 @@ Once you have buffered javascript, you can output it as you would any other
561561 // In your layout
562562 echo $this->fetch('script');
563563
564+ Creating Javascript Importmap
565+ -----------------------------
566+
567+ .. php :method :: importmap(array $map, array $options = []): string
568+
569+ Creates an `importmap ` script tag for your JavaScript files::
570+
571+ // In the head tag of your layout
572+ echo $this->Html->importmap([
573+ 'jquery' => 'jquery.js',
574+ 'wysiwyg' => '/editor/wysiwyg.js'
575+ ]);
576+
577+ Will output:
578+
579+ .. code-block :: html
580+
581+ <script type =" importmap" >{
582+ " imports" : {
583+ " jquery" : " /js/jquery.js" ,
584+ " wysiwyg" : " /editor/wysiwyg.js"
585+ }
586+ } </script >
587+
588+ Generating maps with imports, scopes and integrity::
589+
590+ echo $this->Html->importmap([
591+ 'imports' => [
592+ 'jquery' => 'jquery-3.7.1.min.js',
593+ 'wysiwyg' => '/editor/wysiwyg.js'
594+ ],
595+ 'scopes' => [
596+ 'scoped/' => [
597+ 'foo' => 'inner/foo',
598+ ],
599+ ],
600+ 'integrity' => [
601+ 'jquery' => 'sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=',
602+ ],
603+ ]);
604+
605+ Will output:
606+
607+ .. code-block :: html
608+
609+ <script type =" importmap" >{
610+ " imports" : {
611+ " jquery" : " /js/jquery-3.7.1.min.js" ,
612+ " wysiwyg" : " /editor/wysiwyg.js"
613+ },
614+ " scopes" : {
615+ " scoped/" : {
616+ " foo" : " /js/inner/foo.js"
617+ }
618+ },
619+ " integrity" : {
620+ " /js/jquery-3.7.1.min.js" : " sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
621+ }
622+ } </script >
623+
564624Creating Nested Lists
565625---------------------
566626
0 commit comments