Merge branch 'MDL-62945-master' of https://github.com/HuongNV13/moodle
[moodle.git] / lib / templates / action_link.mustache
blob0616c6345cb2b78b7261b1c9259fdd6fad6fd912
1 {{!
2     This file is part of Moodle - http://moodle.org/
4     Moodle is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
9     Moodle is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
14     You should have received a copy of the GNU General Public License
15     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
17 {{!
18     @template core/action_link
20     Action link template.
22     Context variables required for this template:
23     * disabled - Flag that indicates whether the action link to be rendered is disabled or not.
24     * url - The action link URL.
25     * id - The ID.
26     * classes - CSS classes for the action link.
27     * attributes - Array of attributes.
28       * name - Attribute name.
29       * value - Attribute value.
30     * icon - The icon context data for this action link.
31     * text - The text for this action link.
33     Example context (json):
34     {
35         "disabled": false,
36         "url": "#",
37         "id": "test-id",
38         "classes": "btn btn-link",
39         "attributes": [
40             {
41                 "name": "title",
42                 "value": "Action link's title"
43             }
44         ],
45         "icon": {
46             "attributes": [
47                 {"name": "src", "value": "https://raw.githubusercontent.com/moodle/moodle/master/pix/t/check.png"},
48                 {"name": "alt", "value": "Action link's icon"}
49             ]
50         },
51         "text": "This is an action link"
52     }
54 {{^disabled}}
55     <a href="{{{url}}}" id="{{id}}" class="{{classes}}" {{#attributes}} {{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}>{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{{text}}}</a>
56     {{#hasactions}}
57         {{> core/actions }}
58     {{/hasactions}}
59 {{/disabled}}
60 {{#disabled}}
61     <span class="currentlink {{classes}}" {{#attributes}} {{name}}={{#quote}}{{value}}{{/quote}} {{/attributes}}>{{#icon}}{{#pix}}{{key}}, {{component}}, {{title}}{{/pix}}{{/icon}}{{{text}}}</span>
62 {{/disabled}}