Singular template
is the standard directory.
Despite the quantity of files in the Magento_Ui templates
directory, that case appears to be a unique instance and why it was done that way is not clear to me. The Magento_Ui module appears to be the only module that uses web/templates
instead of web/template
. There is a requirejs-config
entry that maps template
to templates
like so:
'ui/template': 'Magento_Ui/templates'
(source: module-ui/view/base/requirejs-config.js
).
The file (module-ui/view/base/web/js/lib/knockout/template/loader.js
) that handles the async requests for templates has a formatPath
method which returns:
return result.replace(/^([^\/]+)/g, '$1/template')
Consequently, if you use template
as the directory, you can be less explicit in loading HTML templates, or you must map it.
For a concrete example of a core module using the template
directory, refer to the Magento_Checkout
module which has a large number of .html
templates in the web/template
directory.
The map was part of one of the first commits: https://github.com/magento/magento2/blame/0865a13d4785221cec11f343ddc3452a77014951/app/code/Magento/Ui/view/base/requirejs-config.js. It would not surprise me if the template
was standardized and Magento_Ui was never updated.