@@ -546,6 +546,78 @@ Beware that templates use a simplified version of the logical path shown above.
546
546
For example, an ``index.html.twig `` template located in the ``templates/Default/ ``
547
547
directory of the AcmeBlogBundle, is referenced as ``@AcmeBlog/Default/index.html.twig ``.
548
548
549
+ Specifics for a UX bundle
550
+ -------------------------
551
+
552
+ Here are a few tricks to make your bundle install as a UX bundle.
553
+
554
+ composer.json file
555
+ ~~~~~~~~~~~~~~~~~~
556
+
557
+ Your ``composer.json `` file must have the ``symfony-ux `` keyword:
558
+
559
+ .. code-block :: json
560
+
561
+ {
562
+ "keywords" : [" symfony-ux" ]
563
+ }
564
+
565
+ Assets location
566
+ ~~~~~~~~~~~~~~~
567
+
568
+ Your assets must be located in one of the following directories, with a ``package.json `` file so Flex can handle it
569
+ during install/update:
570
+
571
+ * ``/assets ``
572
+ * ``/Resources/assets ``
573
+ * ``/src/Resources/assets ``
574
+
575
+ package.json file
576
+ ~~~~~~~~~~~~~~~~~
577
+
578
+ Your ``package.json `` file must contain a ``symfony `` config with controllers defined, and also add required packages
579
+ to the ``peerDependencies ``:
580
+
581
+ .. code-block :: json
582
+
583
+ {
584
+ "name" : " @acme/feature" ,
585
+ "symfony" : {
586
+ "controllers" : {
587
+ "slug" : {
588
+ "main" : " dist/controller.js" ,
589
+ "webpackMode" : " eager" ,
590
+ "fetch" : " eager" ,
591
+ "enabled" : true ,
592
+ "autoimport" : {
593
+ "dist/bootstrap4-theme.css" : false ,
594
+ "dist/bootstrap5-theme.css" : true
595
+ }
596
+ }
597
+ }
598
+ },
599
+ "peerDependencies" : {
600
+ "@hotwired/stimulus" : " ^3.0.0" ,
601
+ "slugify" : " ^1.6.5"
602
+ }
603
+ }
604
+
605
+ In this case, the file located at ``[assets directory]/dist/controller.js `` will be exposed.
606
+
607
+ If the bundle is named ``acme/feature ``, the base key for the controller will be ``acme--feature--slug ``: it's composed
608
+ of the bundle name and the controller name defined in the ``package.json `` file.
609
+
610
+ To use it in a template (eg. one defined in your bundle) you can use it like this:
611
+
612
+ .. code-block :: twig
613
+
614
+ <div
615
+ data-controller="acme--feature--slug"
616
+ data-acme--feature--slug-modal-value="my-value"
617
+ >
618
+ ...
619
+ </div>
620
+
549
621
Learn more
550
622
----------
551
623
0 commit comments