diff --git a/mod/wiki/classes/output/quick_search_form.php b/mod/wiki/classes/output/quick_search_form.php
new file mode 100644
index 0000000..eef9bef
--- /dev/null
+++ b/mod/wiki/classes/output/quick_search_form.php
@@ -0,0 +1,78 @@
+<?php
+// 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 <http://www.gnu.org/licenses/>.
+
+/**
+ * Quick search form renderable.
+ *
+ * @package    mod_wiki
+ * @copyright  2021 LTD "OPEN TECHNOLOGY"
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace mod_wiki\output;
+defined('MOODLE_INTERNAL') || die();
+
+use moodle_url;
+use renderable;
+use renderer_base;
+use templatable;
+
+/**
+ * Quick search form renderable class.
+ *
+ * @package    mod_wiki
+ * @copyright  2021 LTD "OPEN TECHNOLOGY"
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class quick_search_form implements renderable, templatable {
+
+    /** @var int The course ID. */
+    protected $courseid;
+    /** @var int Course module ID. */
+    protected $cmid;
+    /** @var int Subwiki ID. */
+    protected $subwikiid;
+    /** @var string Current query. */
+    protected $query;
+    /** @var moodle_url The form action URL. */
+    protected $actionurl;
+
+    /**
+     * Constructor.
+     *
+     * @param int $courseid The course ID.
+     * @param string $query The current query.
+     */
+    public function __construct($courseid, $cmid, $query = '', $subwikiid=null) {
+        $this->courseid = $courseid;
+        $this->cmid = $cmid;
+        $this->query = $query;
+        $this->subwikiid = $subwikiid;
+        $this->actionurl = new moodle_url('/mod/wiki/search.php');
+    }
+
+    public function export_for_template(renderer_base $output) {
+        $data = [
+            'actionurl' => $this->actionurl->out(false),
+            'courseid' => $this->courseid,
+            'cmid' => $this->cmid,
+            'query' => $this->query,
+            'subwikiid' => $this->subwikiid,
+        ];
+        return $data;
+    }
+
+}
diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php
index cb42b9f..51d3b4b 100644
--- a/mod/wiki/lib.php
+++ b/mod/wiki/lib.php
@@ -441,28 +441,24 @@
     }
 }
 
+/**
+ * @param object $cm
+ * @param string $search
+ * @param object|NULL $subwiki
+ * @return string
+ */
 function wiki_search_form($cm, $search = '', $subwiki = null) {
-    global $CFG, $OUTPUT;
-
-    $output = '<div class="wikisearch">';
-    $output .= '<form method="post" action="' . $CFG->wwwroot . '/mod/wiki/search.php" style="display:inline">';
-    $output .= '<fieldset class="invisiblefieldset">';
-    $output .= '<legend class="accesshide">'. get_string('searchwikis', 'wiki') .'</legend>';
-    $output .= '<label class="accesshide" for="searchwiki">' . get_string("searchterms", "wiki") . '</label>';
-    $output .= '<input id="searchwiki" name="searchstring" type="text" size="18" value="' . s($search, true) . '" alt="search" />';
-    $output .= '<input name="courseid" type="hidden" value="' . $cm->course . '" />';
-    $output .= '<input name="cmid" type="hidden" value="' . $cm->id . '" />';
-    if (!empty($subwiki->id)) {
-        $output .= '<input name="subwikiid" type="hidden" value="' . $subwiki->id . '" />';
+    global $PAGE;
+    $subwikiid = null;
+    if (!empty($subwiki->id))
+    {
+        $subwikiid = $subwiki->id;
     }
-    $output .= '<input name="searchwikicontent" type="hidden" value="1" />';
-    $output .= '<input value="' . get_string('searchwikis', 'wiki') . '" class="btn btn-secondary" type="submit" />';
-    $output .= '</fieldset>';
-    $output .= '</form>';
-    $output .= '</div>';
-
-    return $output;
+    $wikisearch = new \mod_wiki\output\quick_search_form($cm->course, $cm->id, s($search, true), $subwikiid);
+    $output = $PAGE->get_renderer('mod_wiki');
+    return $output->render($wikisearch);
 }
+
 function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm) {
     global $CFG, $PAGE, $USER;
 
diff --git a/mod/wiki/templates/quick_search_form.mustache b/mod/wiki/templates/quick_search_form.mustache
new file mode 100644
index 0000000..a371c73
--- /dev/null
+++ b/mod/wiki/templates/quick_search_form.mustache
@@ -0,0 +1,47 @@
+{{!
+    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 <http://www.gnu.org/licenses/>.
+}}
+{{!
+    @template mod_wiki/quick_search_form
+
+    This template renders the search form within wikis.
+
+    Example context (json):
+    {
+        "actionurl": "https://domain.example/mod/wiki/search.php",
+        "courseid": "16",
+        "cmid": "168",
+        "query": "find this post",
+        "subwikiid": "2",
+    }
+}}
+<div class="wikisearch">
+    <form method="post" action="{{actionurl}}" class="form-inline">
+        <input type="hidden" name="searchwikicontent" value="1">
+        <input type="hidden" name="courseid" value="{{courseid}}">
+        <input type="hidden" name="cmid" value="{{cmid}}">
+        {{#subwikiid}}
+        <input type="hidden" name="subwikiid" value="{{subwikiid}}">
+        {{/subwikiid}}
+        <div class="input-group">
+            <label class="sr-only" for="searchwiki">{{#str}}searchterms, wiki{{/str}}</label>
+            <input id="searchwiki" name="searchstring" type="text" class="form-control" value="{{query}}" alt="search">
+            <div class="input-group-append">
+                <button class="btn btn-secondary" type="submit">{{#str}}searchwikis, mod_wiki{{/str}}</button>
+            </div>
+        </div>
+    </form>
+</div>
