MDL-69262 core: Use core/action_menu_link in core/action_menu_trigger
authorJun Pataleta <jun@moodle.com>
Thu, 27 Aug 2020 05:23:24 +0000 (13:23 +0800)
committerJun Pataleta <jun@moodle.com>
Thu, 27 Aug 2020 05:29:40 +0000 (13:29 +0800)
* Introduce the "actionmenulinkclasses" block in the action_menu_link
template so other templates importing it can have the option to override
its classes.
* Have the action menu trigger template use the action menu link
template to reduce code duplication.

lib/templates/action_menu_link.mustache
lib/templates/action_menu_trigger.mustache

index 0184d49..a57beb2 100644 (file)
     }
 }}
 {{^disabled}}
-    <a href="{{url}}" class="aabtn {{classes}}" {{#attributes}}{{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}{{#showtext}}aria-labelledby="actionmenuaction-{{instance}}"{{/showtext}}>{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{#showtext}}<span class="menu-action-text" id="actionmenuaction-{{instance}}">{{{text}}}</span>{{/showtext}}</a>
+    <a href="{{url}}" class="{{$actionmenulinkclasses}}aabtn {{classes}}{{/actionmenulinkclasses}}" {{#attributes}}{{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}{{#showtext}}aria-labelledby="actionmenuaction-{{instance}}"{{/showtext}}>
+        {{#icon}}
+            {{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}
+        {{/icon}}
+        {{#showtext}}
+            <span class="menu-action-text" id="actionmenuaction-{{instance}}">{{{text}}}</span>
+        {{/showtext}}
+    </a>
 {{/disabled}}
 {{#disabled}}
     <span class="currentlink" role="menuitem">{{#icon}}{{#pix}}{{key}},{{component}},{{title}}{{/pix}}{{/icon}}{{{text}}}</span>
index 8a172c9..9c009fc 100644 (file)
         <div class="dropdown-menu dropdown-menu-right {{classes}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}>
             {{#items}}
                 {{#actionmenulink}}
-                    <a href="{{url}}" class="dropdown-item {{classes}}" {{#attributes}}{{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}{{#showtext}}aria-labelledby="actionmenuaction-{{instance}}"{{/showtext}}>
-                        {{#icon}}
-                            {{#pix}}{{key}},{{component}},{{title}}{{/pix}}
-                        {{/icon}}
-                        {{#showtext}}
-                        <span class="menu-action-text" id="actionmenuaction-{{instance}}">
-                            {{{text}}}
-                        </span>
-                        {{/showtext}}
-                    </a>
+                    {{< core/action_menu_link}}
+                        {{$actionmenulinkclasses}}dropdown-item {{classes}}{{/actionmenulinkclasses}}
+                    {{/ core/action_menu_link}}
                 {{/actionmenulink}}
                 {{#actionmenufiller}}
                     <div class="dropdown-divider" role="presentation"><span class="filler">&nbsp;</span></div>