How to render plugin templates in Craft CMS 3?
After becoming more familiar with Craft and Yii, I've found a more appropriate solution for my use case. I have a couple of ideal requirements:


Templates are stored in a directory within my module or plugin.
Templates can be mixed with general application templates (e.g. my module or plugin template can extend from a general site layout template).


It turns out that the Template Roots functionality enables this, so it is documented but for some reason I was overlooking this previously.

You can simply register the template root during plugin/module init like so:

Event::on(View::class, View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS, function (RegisterTemplateRootsEvent $event) {
   $event-&gt;roots['_my_prefix'] = __DIR__ . '/templates';
});


Then templates in the defined directory can be rendered using the defined prefix (_my_prefix in this case), as though that directory exists in the main templates directory. This means they can be used in any context and extend or include templates in the main directory ‒ desirable for app specific plugins/modules.