Calling drupal_find_theme_templates() in a theme directory with a field called node--banner-tab.haml
You get:
Array
(
[] => Array
(
[template] =>
[path] => sites/all/themes/cti/templates
[render element] => elements
[base hook] => node
)
)
Should get:
Array
(
[node__banner_tab] => Array
(
[template] => node--banner-tab
[path] => sites/all/themes/cti/templates
[render element] => elements
[base hook] => node
)
)
Due to drupal_scan_directory() using pathinfo() to get the basename of template files, files named something.tpl.php will be returned as something.tpl. This is handled correctly for standard templates (checks to see if there is an extraneous extension before stripping it), but for dynamic templates it assumes that it will have an extension and attempts to strip it. This massively breaks when you're using a theme engine that only uses one extension for templates (such as ".haml", as used by Peroxide).
I've attached a patch to fix the handling in all cases.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | theme-system-file-extension-removal-1120798-3.patch | 836 bytes | oadaeh |
| patch_commit_ad6b6cffcbbd.patch | 817 bytes | randomblast |
Comments
Comment #1
randomblast commentedComment #2
xjmpatch_commit_ad6b6cffcbbd.patch queued for re-testing.
Comment #3
oadaeh commentedI've recreated the patch for the current state of D8. The code seems fine, but I'm not entirely sure how to test that it does what is claims to do.
Comment #6
oadaeh commentedConsidering this is now nearly three years old, is this still a valid issue?
Looking at that function now, it no longer resembles what the patch was against and processes the files in a different way:
Comment #7
star-szrI can confirm this was fixed in D8 by #1900458-13: Use .html.twig instead of .twig file extension, in particular see the interdiff there.
A similar approach should probably work fine for D7 because drupal_find_theme_templates() still gets an extension passed in. However, this change could be slightly risky. Changing the version accordingly so this can be considered, and bugs need tests.
Thanks for bumping this @oadaeh :)