Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
It's my understanding that theme functions are deprecated, and that Twig templates should usually be used instead. Developers will expect to see a Twig template in general, and may not think to look for a theme function. Lastly, some themes don't even have a .theme file, which makes adds an extra step to overriding the markup produced by this module.
Proposed resolution
Instead of a theme function, use a Twig template.
Comment | File | Size | Author |
---|---|---|---|
#5 | Screenshot 2020-05-27 at 10.02.53.png | 152.52 KB | John Cook |
#4 | 2903451-twig-template-instead-of-theme-function-3.patch | 906 bytes | Leon Kessler |
#2 | 2903451-twig-template-instead-of-theme-function-2.patch | 902 bytes | Leon Kessler |
Comments
Comment #2
Leon Kessler CreditAttribution: Leon Kessler commentedAgreed, a twig template should be the way forward.
I realise this may break some sites already relying on the theme function, so perhaps this needs 8.3.x release (although the 8.2.x branch is still in beta).
Anyway it should be a pretty simple switch. Something like.....
Comment #4
Leon Kessler CreditAttribution: Leon Kessler commentedNeeded to add a
|raw
into the twig file, as the spans are already rendered (so are getting escaped inside of twig). It's not very pretty, but can be fixed in child ticket: #2929460: Avoid rendering spans directly in the serviceComment #5
John Cook CreditAttribution: John Cook at Creode commentedI've had a look at the patch.
It applies well and only changes the the method how the markup is rendered.
The blocks are displayed as expected.
After patch:
As this issue is part of Drupal 9 compatibility, I've tagged as such.
Excerpt of compatibility report:
The other issues are addressed in #3076535: Remove the usage of deprecated functions/methods/classes.
So I'm marking as RTBC.
Comment #6
naveenvalechaCommitted and pushed to 8.x-2.x