diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php
index 9acc0402824..71eafc2447e 100644
--- a/lib/outputcomponents.php
+++ b/lib/outputcomponents.php
@@ -499,6 +499,8 @@ class help_icon implements renderable, templatable {
* @return array
*/
public function export_for_template(renderer_base $output) {
+ global $CFG;
+
$title = get_string($this->identifier, $this->component);
if (empty($this->linktext)) {
@@ -508,7 +510,16 @@ class help_icon implements renderable, templatable {
}
$data = get_formatted_help_string($this->identifier, $this->component, false);
+
$data->alt = $alt;
+ $data->icon = (new pix_icon('help', $alt, 'core', ['class' => 'iconhelp']))->export_for_template($output);
+ $data->linktext = $this->linktext;
+ $data->title = get_string('helpprefix2', '', trim($title, ". \t"));
+ $data->url = (new moodle_url($CFG->httpswwwroot . '/help.php', [
+ 'component' => $this->component,
+ 'identifier' => $this->identifier,
+ 'lang' => current_language()
+ ]))->out(false);
$data->ltr = !right_to_left();
return $data;
diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
index cd203f1784a..280e8004dc3 100644
--- a/lib/outputrenderers.php
+++ b/lib/outputrenderers.php
@@ -2412,39 +2412,7 @@ class core_renderer extends renderer_base {
* @return string HTML fragment
*/
protected function render_help_icon(help_icon $helpicon) {
- global $CFG;
-
- // first get the help image icon
- $src = $this->pix_url('help');
-
- $title = get_string($helpicon->identifier, $helpicon->component);
-
- if (empty($helpicon->linktext)) {
- $alt = get_string('helpprefix2', '', trim($title, ". \t"));
- } else {
- $alt = get_string('helpwiththis');
- }
-
- $attributes = array('src'=>$src, 'alt'=>$alt, 'class'=>'iconhelp');
- $output = html_writer::empty_tag('img', $attributes);
-
- // add the link text if given
- if (!empty($helpicon->linktext)) {
- // the spacing has to be done through CSS
- $output .= $helpicon->linktext;
- }
-
- // now create the link around it - we need https on loginhttps pages
- $url = new moodle_url($CFG->httpswwwroot.'/help.php', array('component' => $helpicon->component, 'identifier' => $helpicon->identifier, 'lang'=>current_language()));
-
- // note: this title is displayed only if JS is disabled, otherwise the link will have the new ajax tooltip
- $title = get_string('helpprefix2', '', trim($title, ". \t"));
-
- $attributes = array('href' => $url, 'title' => $title, 'aria-haspopup' => 'true', 'target'=>'_blank');
- $output = html_writer::tag('a', $output, $attributes);
-
- // and finally span
- return html_writer::tag('span', $output, array('class' => 'helptooltip'));
+ return $this->render_from_template('core/help_icon', $helpicon->export_for_template($this));
}
/**
diff --git a/lib/templates/help_icon.mustache b/lib/templates/help_icon.mustache
new file mode 100644
index 00000000000..d73c8c3201c
--- /dev/null
+++ b/lib/templates/help_icon.mustache
@@ -0,0 +1,22 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see .
+}}
+{{!
+ Help icon.
+}}
+
+ {{#icon}}{{>core/pix_icon}}{{/icon}}{{#linktext}}{{.}}{{/linktext}}
+