template associated with views style-plugin, and then customized for particular view: views does not find template I have a style plugin, 'mystyle'. And I created a view, 'myview', with style set to 'mystyle'.

Here is the declaration of 'mystyle' in hook_view_plugins:

function mymodule_views_plugins() {
  $plugins = array(
    'module' =&gt; 'mymodule',
    'style' =&gt; array(
      'mystyle' =&gt; array(
        'title' =&gt; t('My Style'),
        'handler' =&gt; 'mymodule_views_plugin_mystyle',
        'theme' =&gt; 'mymodule_views_plugin_mystyle_template',
        'uses fields' =&gt; TRUE,
        'uses row plugin' =&gt; FALSE,
        'uses options' =&gt; TRUE,
        'uses grouping' =&gt; FALSE,
        'type' =&gt; 'normal',
        'even empty' =&gt; FALSE,
      ),
    )
  );
  return $plugins;
}


I have the following files in mymodule/views:

(handler)
mymodule_views_plugin_mystyle.inc

(template associated with this style)
mymodule-views-plugin-mystyle-template.tpl.php

(template associated with this style, and customized for the view 'myview')
mymodule-views-plugin-mystyle-template--myview.tpl.php

My problem:
Views is using the first, less specific, template (mymodule-views-plugin-mystyle-template.tpl.php) to display this view.

When I edit 'myview' and click on "theme information", I see both templates listed under "style output":


mymodule-views-plugin-mystyle-template.tpl.php
mymodule-views-plugin-mystyle-template--myview.tpl.php


The first, less specific, template is in bold. If I understand correctly, this means that views found the first template but did not find the second.

I have tried rescanning, but that does not help. I have also tried deleting the cache.

Should this work? What do I need to do to get views to find the more specific template?
Drupal by default doesn't scan for more specific templates in modules directories, but views allows you to do it by adding 'template path' to hook_views_api(), see: https://api.drupal.org/api/views/views.api.php/function/hook_views_api/7.x-3.x