Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Issue #2152207 by steveoliver, joelpittet, gnuget, idflood, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_details() to Twig
Task
Convert theme_details() to a Twig template.
Remaining tasks
Patch- Patch review
Manual testingProfiling
Steps to test
Visit /admin/appearance/settings
Review the form output of the <detail>
tags
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 4.22 KB | joelpittet |
#18 | 2152207-twig-theme-details-18.patch | 11.13 KB | joelpittet |
#14 | 2152207-6-theme_details.patch | 11.16 KB | gnuget |
#4 | interdiff.txt | 5.34 KB | joelpittet |
#4 | 2152207-4-theme_details.patch | 8.02 KB | joelpittet |
Comments
Comment #1
star-szrAdding a commit message to the issue summary so the folks who already worked on #1898480: [meta] form.inc - Convert theme_ functions to Twig and in the Twig sandbox get credit.
Comment #2
joelpittetSplit from form.inc twig conversion.
Comment #4
joelpittetFixed the whitespace errors and did some clean-up.
Comment #5
John Pitcairn CreditAttribution: John Pitcairn commentedShouldn't there be a div.description in here?
div.details-description does not receive the same text formatting as div.description, which makes form help text look inconsistent, and requires extra work for themes to override.
If there is a div.details-wrapper I'd expect to find a div.details inside that, or else the wrapper should be div.details-description-wrapper.
I think ideally this should be changed to:
<div class="details description">
There are only two lines in core css targeting .details-description (in user.module.css and bartik style.css) - these would need to change to .details.description. Any objections?
Comment #6
joelpittet@John Pitcairn those are great suggestions though not particularly for this issue. Have a look here and help @mortendk #1980004: [meta] Creating Dream Markup if there is not for theme_details() an issue, you're welcome to create it and add it to the meta with exactly what you wrote in the comment above.
This issue is related to getting the conversion of a theme_* function to a twig file. We won't introduce markup or style changes as we are comparing that we haven't made a mistake in the conversion process.
If you want to help with this issue still, we need someone to compare the markup before and after the patch is applied to make sure we didn't break anything existing. That would help get this theme_ function die and get the template as twig in core so it would be easier for you to manipulate the markup to your liking.
Comment #7
John Pitcairn CreditAttribution: John Pitcairn commentedThought somebody might say that ;-)
Will do. Sorry I can't test this immediately, we are building a site on alpha 7.
Issue is here: #2177813: details.html.twig should include .description class
Comment #8
joelpittetComment #9
joelpittetDue to either spaceless of the minus whitespace removers there is missing space between input's and their labels. My guess is spaceless. I'd rather not use spaceless, but that means fixing the whitespace in the tests.
Comment #10
gnugetI'm going to upload a version without the spaceless tag for see exactly which tests fails
After that i'm going to work on fix them.
Comment #11
joelpittetStarting up the testbot (needs review). To see if there are any tests we need to fix. Hopefully we can do xpath equivalent tests to help ignore whitespace differences. Thanks @gnuget
Comment #13
joelpittet@gnuget the tests are in-line with the ones you found. It says "ForumUninstallTest" too but I doubt that fail is real(bot anomaly)...
Buena suerte!
Comment #14
gnugetOk, here a patch which replace the failing tests with their xpath equivalents
Comment #15
MartiMcFlight CreditAttribution: MartiMcFlight commentedThe rendered code before the patch is the same as the rendered code after the patch. Only the order of some tag attributes and ids or classes has changed, but this does not break the applied css. The page looks exactly the same in the browser.
I haven’t done profiling but i’m not sure if it is necessary for this issue since the theme details won’t be changed often, so performance is not critical.
Comment #16
MartiMcFlight CreditAttribution: MartiMcFlight commentedComment #17
idflood CreditAttribution: idflood commentedI profiled the patch in #14. I wasn't sure about the results so I did this multiple times and the results were always similar.
I've also looked at the markup and it looks ok (same as #15).
Now the only thing missing is a proper patch review.
Comment #18
joelpittetI reviewed the xpath and the patch and did some minor cleanup but I believe this captures all that is expected from the markup without the whitespace differences. Great work.
Comment #19
joelpittetOh I did a manual review on this already and reviewed the new xpath changes, so this is good to go. Testbot can disagree if it wants but I think this is RTBC.
Comment #20
joelpittetAlso thanks for profiling @idflood and the test changes @gnuget!
Comment #21
star-szrAdding some folks to the proposed commit message :)
Comment #22
star-szrComment #23
webchickCommitted and pushed to 8.x. Thanks!