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.
Meta issue: #1843738: [meta] Convert views module to Twig
#1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch
Steps to test:
1. Add at least two articles
2. Edit front page view to be formatted as a list
3. Add "grouping" to the formatting so list titles are rendered
4. Visit the front page
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 814 bytes | shanethehat |
#18 | twig-views-view-list-1843754-18.patch | 4.1 KB | shanethehat |
#16 | interdiff.txt | 936 bytes | shanethehat |
#16 | twig-views-view-list-1843754-16.patch | 4.09 KB | shanethehat |
#13 | 1843754-13-twig-views-view-list.patch | 3.96 KB | joelpittet |
Comments
Comment #1
joelpittetNot sure how to translate this one:
I would assume move towards this:
Comment #2
mbrett5062 CreditAttribution: mbrett5062 commentedTagging.
Comment #3
joelpittetMoving to core queue
Comment #4
joelpittetOk did the simple way to convert this, would prefer to rework the preprocessor to be closer to the second option in #1 but want to see if this will pass.
There are quite a few fails in the views module locally on my d8clean.dev as well but no obvious ones for this conversion so here goes nothing.
Comment #5
joelpittettitle update
Comment #6
star-szrTagging.
Comment #7
joelpittetComment #8
dawehner@joelpittet
Do you have any preferences, whether all this twig issues or the improvements of the variables should get in first?
Comment #9
thedavidmeister CreditAttribution: thedavidmeister commentedReview for #4:
wrapper_prefix, wrapper_suffix, rows and row_classes are variables used in the Twig template but not documented in the template.
This is not how we document preprocess functions. See #1913208: [policy] Standardize template preprocess function documentation.
We don't need these prefix/suffix variables, just the class. The div markup should be markup in the template.
Same for this. Surely we don't need prefix/suffix but just
<{{ list_type}} {{ attributes }}> ... </{{ list_type}}>
in the Twig template.Is it ok to call one preprocess directly from within another?
Comment #10
joelpittet@dawehner re #14 I do not have a preference... same work to me either way.
Reworked the html strings out of the template. Had to add the wrapper if because it seems to only show up if there are classes to apply to it.
Comment #11
joelpittet@thedavidmeister on your last point, I am not sure... that is how it was. @dawehner you may be able to answer that one?
Comment #13
joelpittetAlthough I think that fail above is fake, I did notice a couple whitespace issues.
Comment #14
jenlamptonWe need to avoid generating a HTML tag by printing a variable in a template like this:
We ran into this in the item-list template, too. See this comment for a workaround.
Related: #1842034: Remove dynamic generation of HTML tags
Comment #15
shanethehat CreditAttribution: shanethehat commentedComment #16
shanethehat CreditAttribution: shanethehat commentedComment #18
shanethehat CreditAttribution: shanethehat commentedDurrr...Friday afternoon coding
Comment #19
thedavidmeister CreditAttribution: thedavidmeister commented#18 - Don't worry, I think the Twig "is" not working as "==" is going to trip lots of people up when D8 gets released. I've done the same thing in my patches too...
Comment #20
dawehnerI'm wondering whether this is okay, as it makes the template pretty complicated.
Comment #21
thedavidmeister CreditAttribution: thedavidmeister commented#20 - @dawehner, see comment #14. You're now just saying the opposite of @jenlampton.
Comment #22
dawehnerAh I'm sorry. I'm not that much into twig.
Comment #23
star-szrInstantiating the Attribute objects is not needed here, they can just be arrays now that #1982024: Lazy-load Attribute objects later in the rendering process only if needed is in.
Comment #24
star-szrSorry, wasn't paying enough attention when I posted #23. #1982024: Lazy-load Attribute objects later in the rendering process only if needed only works for 'attributes', 'title_attributes', and 'content_attributes'. Carry on :)
Comment #25
thedavidmeister CreditAttribution: thedavidmeister commentedSorry, I can't see where the manual testing was done for this issue. Feel free to RTBC and remove the tag or do the manual testing.
Comment #26
thedavidmeister CreditAttribution: thedavidmeister commentedi'll do it.
Comment #27
thedavidmeister CreditAttribution: thedavidmeister commentedpost-patch markup:
pre-patch markup:
Comment #28
thedavidmeister CreditAttribution: thedavidmeister commentedwith "normalised" whitespace for easy diffing:
pre:
post:
Comment #29
thedavidmeister CreditAttribution: thedavidmeister commentedComment #30
thedavidmeister CreditAttribution: thedavidmeister commentedComment #30.0
thedavidmeister CreditAttribution: thedavidmeister commentedUpdated issue summary.
Comment #31
star-szrGreat, thanks!
Comment #32
star-szrTagging for profiling.
Comment #33
mr.baileysAssigning to myself for profiling.
Comment #34
mr.baileys3 nodes on front page, rendered through views-view-list:
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519af7f3cd409&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=519af7f3cd409&...
edit: updated run.
edit2: another update, previous run was with twig_debug still enabled.
Comment #35
mr.baileysComment #36
thedavidmeister CreditAttribution: thedavidmeister commentedComment #37
alexpott+1. Ready for #1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch
Comment #38
alexpottCommitted 5717861 and pushed to 8.x. Thanks!
Comment #39.0
(not verified) CreditAttribution: commentedadded testing steps