Fixing theme bug where dir must exist in core + expanded "default" fallback #114
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hiya!
I noticed two issues with the theming system:
If you use
$configuration->setTheme('my_theme');
, Twig would ALWAYS try to lookfor a
lib/Templates/my_theme
directory (inside rst-parser itself), which would cause an exception. Setting themes was unusable.There are two reasons to put "override" templates inside a library that uses
rst-parser
:A) to override individual pieces (e.g.
paragraph.html.twig
)B) to override
layout.html.twig
for themeingPreviously, if you had 2 themes (
theme_foo
andtheme_bar
), each with their ownlayout.html.twig
file, there was no place to put the overrides for part (A): the system would ONLY look inside the active theme directory for ALL overrides (soparagraph.html.twig
would need to live in both directories, so that it was found when you switched).There was already a "fallback" concept: look inside the user's "theme" directory, then fallback to the
default
directory in core. I expanded that to always look for the theme directory first, but then look for a directory calleddefault
in all template directories. This allows you to put all your "component" overrides in adefault
directory, then ONLY yourlayout.html.twig
in the theme directory (though you could still override "components" there if you need to).Test included and is BC... because themes weren't working properly yet :).
Cheers!