This repository was archived by the owner on Apr 8, 2025. It is now read-only.
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Use an inline html template for search results and search result customization #117
Open
Description
In #116 Underscore was removed, and the pattern was shifted to native DOM manipulation.
One potential pattern to consider for future releases could be to use an HTML template inline in the output, as a Sphinx template. Effectively:
<html>
<head>
<script type="text/html" id="search-template">
<div class="search__header">
{{ _("Search results") }}
<div class="outer__html">
<div class="header">
...
</div>
...
</div>
</script>
</head>
</html>
This gives a template that can be targeted by our search JS, and manipulation of the template would happen with some data binding logic, or a more simple DOM search and replace.
The benefit here is that it is customizable at the Sphinx theme/template level, and can incorporate localization during the Sphinx build. Currently the search window will always be English. Localization is also possible in the JS now, but would have to be an additional step to be hooked into during building.