Problem/Motivation
As mentioned in #3050389: [META] Remove dependency to Classy from core themes, Classy will be moved to contrib before Drupal 9 and we have to remove dependencies on Classy from all core themes. Part of removing these dependencies includes providing each theme their own copies of templates that previously belonged to Classy.
There's considerable potential for error when copying ~100 templates to four different themes, so we need a test that removes some of the uncertainty from the process.
Proposed resolution
Create a test that confirms that themes do not inherit templates from Classy, and that none of the templates they use include/extend Classy templates or attach Classy libraries.
The test will include a per-theme ignore-list of templates that do not need to be included as part of the test. At first, the ignore-lists will be very large, and will shrink with each template-copying issue filed. When a new template-copying issue is filed (for example, copy aggregator templates to Bartik), the first patch will be this test, but with aggregator's templates removed from Bartik's ignore list. This way, the test won't pass until the templates are properly copied.
Every Classy-inheriting core theme currently extends, includes or attaches something from Classy, so these tests will not pass at first.
Remaining tasks
Write the test, configured it to ignore templates that still need to be copied.
Create issues to address existing attach_library() calls to Classy libraries in Bartik/Seven/Claro/Umami, as these will cause the test created here to fail.
- Umami calls
{{ attach_library('classy/node') }}
in node--article--full.html.twig, node--card--common.html.twig, node--card.html.twig, node.html.twig - Bartik calls
{{ attach_library('classy/node') }}
in node.html.twig - Claro calls
{{ attach_library('classy/file') }}
in file-link.html.twig - Seven calls
{{ attach_library('classy/image-widget') }}
in image-widget.html.twig
These library-copying followup issues can't be created until #3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton is complete.
The Classy template include/require's should be addressed in the scope of this issue as this is where the test exists to verify they were done properly. This needs to be addressed with the following:
- Bartik
{% extends ""@classy/block/block--search-form-block.html.twig"" %}
in block--search-form-block.html.twig - Bartik
{% extends "@classy/block/block--system-menu-block.html.twig" %}
in block--system-menu-block.html.twig - Bartik
{% extends "@classy/content/page-title.html.twig" %}
in page-title.html.twig - Bartik
{% extends "@classy/misc/status-messages.html.twig" %}
in status-messages.html.twig - Seven
{% include '@classy/content-edit/image-widget.html.twig' %}
in image-widget.html.twig - Claro
{% extends '@classy/form/form-element-label.html.twig' %}
in form-element-label.html.twig
The template copying can't happen until #3095713: Create classy directory with README, in the templates and css directories for all themes subtheming Classy is complete
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
n/a
Comment | File | Size | Author |
---|---|---|---|
#32 | 3096349-27.again_.patch | 31.38 KB | dww |
#27 | 3096349-27.patch | 31.38 KB | bnjmnm |
#27 | interdiff_25-27.txt | 1.1 KB | bnjmnm |
#25 | 3096349-25.patch | 31.42 KB | bnjmnm |
#25 | interdiff_20-25.txt | 4.45 KB | bnjmnm |
Comments
Comment #2
bnjmnmThis test will fail as it checks for templates in Claro/Bartik/Seven/Umami that include/extend/attach Classy assets. This issue can't be completed until #3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton #3095713: Create classy directory with README, in the templates and css directories for all themes subtheming Classy are addressed, but not setting to postponed as the test itself can still be reviewed and moved forward without those issues being done yet.
Comment #4
lauriiiComment #5
bnjmnmUpdated the test to skip the templates identified as identical to stable in #3098150: Add test coverage to ensure Classy templates that have identical versions in Stable are kept in sync
The test will still fail as it fails on templates including or extending Classy assets. Those will be changed in separate issues once #3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton is done.
Comment #6
dwwWhat's the relationship of this to #3083275: [meta] Update tests that rely on Classy to not rely on it anymore?
Should this also be blocked on that?
Or shall they basically happen in parallel?
Thanks,
-Derek
Comment #7
bnjmnmThanks for pointing that out. If I'm correctly understanding #3083275: [meta] Update tests that rely on Classy to not rely on it anymore, there shouldn't be any dependencies between the issues and they can be done in parallel. This issue is for tests that confirm core themes do not depend on Classy templates, while #3083275 is to update existing tests so they do not rely on Classy.
Comment #8
dwwAgreed. Added it as a child of #3050378: [meta] Replace Classy with a starterkit theme instead.
Thanks,
-Derek
Comment #9
lauriii#3098150: Add test coverage to ensure Classy templates that have identical versions in Stable are kept in sync has been committed.
Comment #10
bnjmnmAs mentioned in the issue summary, there are six templates that include or extend Classy templates. Those include/extends should be addressed in the scope of this issue. Prior to doing that work, I'm providing these fail patches to show the the test catching this happening. One test for each bartik include/extend, and one that covers the occurrence in Claro and the occurrence in Seven.
Comment #11
bnjmnmThis patch addresses the 6 templates in Classy-inheriting themes that include or extend
@classy/
templates. They have been refactored to provide the same functionality without the presence of a Classy template.The library related assertions in ThemesNotUsingClassyTemplatesTest are commented out in this patch so the testgroups can perform the extend/include assertions on each template without an expected attach_library() fail preventing completion.
A zip of before/after screenshots of each template in use is attached, with no change, and the markup was compared as well:
Bartik: block--search-form-block.html.twig
No change
Bartik: block--system-menu-block.html.twig
No change
Bartik page-title.html.twig
No change
<h1 class="title page-title"><span class="field field--name-title field--type-string field--label-hidden" property="schema:name">Cool image</span></h1>
Bartik status-messages.html.twig
No change
Seven image-widget.html.twig
No change
Claro form-element-label.html.twig
No change
<label class="form-item__label js-form-required form-required" for="edit-title-0-value">Title</label>
Another patch is on the way with expanded documentation based on feedback from a sibling issue: #3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton
Comment #12
bnjmnmUpdated docs and removed a few bits of unnecessary code. The tests will still not pass until #3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton is committed and theme-specific versions of the Classy libraries are created so the templates can library_attach() a non-Classy library. All test fails should be due to library use.
Comment #13
lauriii#3096203: Create Classy library dependency tests that can be used for all themes, and verify by providing an Umami-specific classy/dropbutton has landed! 🎉
Comment #15
bnjmnmThis is still postponed due #3106600: Decouple Classy libraries from Umami and some not-yet-created issues. There are overridden templates in all four Classy-inheriting themes that call
attach_library()
to Classy libraries, and these need to be changed to non-Classy equivalents before the tests will pass.Once #3106600: Decouple Classy libraries from Umami is committed, we'll have an established the procedure for copying Classy libraries, and it may be possible to create an issue for making non-Classy copies of just the libraries required to get the tests in this issue passing. This would allow this issue to move forward without waiting for the full library copying to happen on all four themes.
Comment #16
xjmI misunderstood the purpose of this issue. We've unblocked decoupling libraries, but not templates, so this issue needs to wait until all the library decoupling is complete. (However, we can get meaningful work in the meanwhile.)
Comment #17
bnjmnmThis addresses Umami's
attach_library()
calls to Classy libraries, which is possible now that #3106600: Decouple Classy libraries from Umami is committed and there are Umami-specific versions of the Classy libraries.Will make similar changes as the library decoupling issues for Seven, Claro and Bartik are committed.
Comment #18
bnjmnmRerolled and addressed the remaining
attach_library()
calls preventing the tests from passing. Interdiff not particularly easy due to the nature of the reroll but hopefully not a problem here since this hasn't been reviewed by anyone yet.Comment #19
bnjmnmComment #20
lauriiiThis will allow us to decouple from Classy but not from Stable. Let's open follow-up also for planning decoupling from Stable.
Should we add double quotes as a valid character to the regex as an extra precaution?
Should we check for this condition first? It seems more logical to me since that way we
don't have to check the
extends|include
andattach_library
from Classy templates.Comment #21
bnjmnmThis takes care of #20 2-3. Will address the followup requested in #1 after I've had the chance to discuss this and clarify a few details.
Comment #22
bnjmnmAdded followup #3110855: Plan for removing dependency to Stable in Bartik/Seven/Claro/Umami
Comment #23
dwwThis looks great. I'm tempted to RTBC it. A few minor nits/?s:
a) Tiny nit: === instead of ==?
b) Maybe this would be more readable with each
|| whatever
clause on a newline?Looks like double ' after $template_name in the assert message.
Are we supposed to say "Data provider for ..."?
Do we need to document the keys?
Yay for adding these! I find accurate docs in twig templates incredibly valuable, and sometimes missing from core patches. Huzzah.
It's been a long day, and my eyes are glazing over trying to closely review the actual template changes included in here. But everything else looks great.
Thanks!
-Derek
Comment #24
lauriiiPiling up on the nitpicks, these lines should be intended with two more spaces.
Comment #25
bnjmnmThis patch addresses all the good details spotted in#23 & #24.
Comment #26
lauriiiNitpick : according to Drupal coding standards, this isn't allowed: https://www.drupal.org/docs/develop/standards/coding-standards#linelength 🔬👁
Comment #27
bnjmnmFor #26
Comment #28
lauriiiThis seems inaccurate but since this has been just copied from the Classy template, it's probably fine for now.
I manually removed
aggregator-feed
from the templates to be skipped and the tests failed, which means that the tests work as expected.Comment #30
dwwRe: #26 / #23.1b: Ugh, I'm so sorry. I've mistaken how I think it should be for what we've actually agreed on. ;) I forgot that #1539712 is still open. Whoops. :( See #1539712-86: [policy, no patch] Coding standards for breaking function calls and language constructs across lines (and some following +1s/comments) for thoughts on why I believe 23.1b is better (easier to read and maintain in the future). Thanks @bnjmnm for implementing it and sorry you had to undo it. ;) Thanks @lauriii for reminding me what's the current reality, not my fantasy. ;)
All that said, +1 to RTBC. This is ready. Don't know what the bot is thinking with #29...
Thanks!
-Derek
Comment #32
dwwBot seems to be confused, and is re-testing #17 for no apparent reason. Re-uploading #27 in the hopes this helps.
Comment #33
Gábor HojtsyComment #35
Gábor HojtsyThanks for the thorough test coverage. Landed!
Comment #36
Gábor HojtsyAlso in 8.9, not sure why it did not show up here. See https://git.drupalcode.org/project/drupal/commit/e3221b6ddc314669f57d5dc...