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.
git commit -m "Issue #1939008 by sun, joelpittet, gnuget, Cottser, drupalninja99, mdrummond, sphism, c4rl, steveoliver, andypost, Fabianx, Gokul N K, longwave | jenlampton: Convert theme_table() to Twig."
Task
Use Twig instead of PHPTemplate
Remaining
- Patch needs review
- Manual testing
Testing steps
Visit admin/structure/types and check the markup for the table displayed.
Comment | File | Size | Author |
---|---|---|---|
#133 | interdiff.txt | 2.37 KB | sun |
#133 | theme.table_.133.patch | 19.23 KB | sun |
#131 | interdiff.txt | 3.97 KB | sun |
#131 | theme.table_.131.patch | 16.86 KB | sun |
#129 | interdiff.txt | 15.14 KB | sun |
Comments
Comment #0.0
jenlamptontop 5
Comment #1
star-szrGoing ahead and creating separate issues for each theme function/template now, so re-titling this one.
Comment #1.0
star-szrThis issue will now be for converting theme_table().
Comment #2
star-szrRelated issue that maybe we can incorporate as part of this conversion issue:
#1868212: Notice: Indirect modification of overloaded element of Drupal\Core\Template\Attribute has no effect (theme_table)
Comment #3
psynaptic CreditAttribution: psynaptic commentedComment #4
psynaptic CreditAttribution: psynaptic commentedI've updated my table twig testing module to work with current Drupal 8.x:
https://github.com/psynaptic/twig-tables
Comment #5
psynaptic CreditAttribution: psynaptic commentedI'm blocked on this as I can't get the twig template to be used, despite the registry having the correct path to the twig template file in the template_file property.
Comment #6
star-szr@psynaptic - thanks for looking at this!
See #1939066: Convert theme_breadcrumb() to Twig for a simple theme.inc patch example. You should define 'template' in drupal_common_theme(), add the Twig template to core/modules/system/templates/table.html.twig, remove the theme() function and possibly add template_preprocess_table().
Comment #7
star-szrAlso, check out #drupal-twig on IRC :)
Comment #8
psynaptic CreditAttribution: psynaptic commentedI did all of these things, except I removed theme_table() and not theme() ;)
Comment #9
star-szrSorry, by that I meant remove the theme_*() function :)
I'm not sure what the template_file you mentioned in #5 is.
Comment #10
psynaptic CreditAttribution: psynaptic commentedMe either, I meant the "template" property of hook_theme().
Comment #11
psynaptic CreditAttribution: psynaptic commentedI just checked my stashed changes and the template file is now recognised. At least I can start working on this now.
Comment #12
tlattimore CreditAttribution: tlattimore commented@psynaptic - whats your status on this? I'd be glad to help out if you'd like.
Comment #13
psynaptic CreditAttribution: psynaptic commented@tlattimore: feel free to take it if you like. I've been working on something else in the meantime and was expecting to get to this soon but my time is running out as I'm going on holiday next week and I have work commitments this week.
Comment #14
joelpittetI took the sandbox conversion + c4rl's last patch and merged it against core. Then touched up a few little things, added a few @todos, tweaked the 2 tests so whitespace and empty classes weren't failing them unfairly. Tried it out on a few pages to see if it's doing ok and seemed to be fairing pretty well.
I have my doubts if this will actually pass all the tests but here goes nothing.
Also, would really like to get rid of 'data' and 'attributes' and replace them with '#attributes' element_children() for everything else. They may be much more involved but my hopes it would make things less 'special case' and more consistent. Please let me know if you are against this idea.
Comment #16
joelpittetSince the way the data was entered in the old _theme_table_cell() auto cast integers as strings I had to add in a little check and cast to help 0's.
Comment #18
joelpittetmissing ending tr and some whitespace mods.
Comment #19
joelpittetactivate
Comment #20
joelpittetdarn wrong patch....
Comment #21
star-szrNice, happy to see a green patch on this issue. Fantastic work @joelpittet, I'll be back for a review.
Comment #22
star-szrAgain, great work on this @joelpittet. Revised patch to address documentation and coding standards. Some notes/further followup:
* //
should only be used for comments within @code…@endcode blocks. I’m not sure if what I’ve changed it to is totally correct either so I'm mentioning it specifically here.Some of these comments could probably be removed, but this is a pretty huge function, so I’d be okay with keeping them.
This comment needs some love, this should be a paragraph or two using complete sentences.
Comment #23
star-szrAdding logic from #1868212-8: Notice: Indirect modification of overloaded element of Drupal\Core\Template\Attribute has no effect (theme_table) but in a slightly different manner. Should do the trick.
Comment #24
star-szrActually in my testing #23 didn't fix the exceptions. Tested in conjunction with #1898034-39: block.module - Convert PHPTemplate templates to Twig. May need to come back to this.
Comment #25
fietserwinThe bug described and solved in #1959110: theme_table outputs the no_striping option as an HTML attribute (followups) which is RTBC and can be committed soon, still appears in this patch. So it will need to be rerolled after the other issue has been committed.
Comment #26
star-szr@fietserwin - thank you for the heads up, I don't think that means the patch needs work just yet though :)
Comment #27
star-szrAlso tagging for manual testing.
Comment #27.0
star-szrAdding sandbox issue to related issues
Comment #28
a.ross CreditAttribution: a.ross commentedThis todo: "Look into removing 'data' and treating this like any other renderable array with element_children and #attributes."
... maybe something worth discussing in #1965214: Improve the theme_table API
Comment #29
star-szrThis will need a quick reroll now that #1961886: Remove 'help' definition from drupal_common_theme() is in.
Comment #30
fietserwinAnd a reroll for #1959110: theme_table outputs the no_striping option as an HTML attribute (followups) now that one is in as well.
Comment #31
star-szrUnassigning, anyone can pick this up and do the re-roll. Instructions: http://drupal.org/patch/reroll
Comment #32
gnugetComment #33
gnugetReroll version of #27
Comment #34
gnugetA fixed version of my previous patch.
Comment #35
gnugetAfter to finish the reroll i found a bug with the "header" attribute in the cells.
With the old theme_table the header attribute in the cells change the "td" for "th", but in the new table.html.twig not exists a condition for replicate that behavior:
I decided before to try to fix this new bug, make sure to my reroll no longer have issues.
David.
Comment #36
star-szr@gnuget - thanks for your work here. The reroll still looks a bit off - I think @joelpittet might need to take a look at this one since he has worked a lot on this issue. Would that be alright? There are other areas you can help with :)
As for the header logic…
Isn't that covered here?
Comment #37
gnugetthe problem with the header, is not the header in self, the problem is the attribute "header" in the cells.
For example, i took this table from the test module of psynaptic (#4, https://github.com/psynaptic/twig-tables)
on this table the first cell of each row has the attribute "header", in the 8.x branch the /includes/theme.inc file have this function:
which before to return the $output check if the cell has the attribute $header, then instead of print a td tag print a th tag, this condition not exists in the twig version right now, and this attribute in the cell is different of the "header" of the table.
About to let to @joelpittet take a look on this, i'm not have any problem, i think to my last reroll just need a bit of more work because that patch passed all the automated tests, i will looking forward for check what i was missing.
Thank you for your help on this.
Comment #38
star-szrUpdating tags. @gnuget, thanks for looking into this issue! This is one of our most complex conversion issues so might not be the best place to jump in :) I should have realized the reroll would not be an easy one. Please drop by IRC when you can.
Comment #39
joelpittet@gnuget I did the merge too. I don't think you missed anything, nice work. And yes you are right, that is a regression for the table cells to not be able to swap between td/th. We should fix that and also write a test to make sure it doesn't happen again. If you want to tackle the fix, I could write the test?
Cheers and nice work. The interdiff is nice to see the differences, probably a bit trickier with a rebase re-roll with merge conflicts:) This patch is just some touchups.
Comment #40
star-szrI should have let @joelpittet review the reroll, my apologies @gnuget. Keep up the great work folks :)
Comment #41
gnuget@joelpittet
I fixed the regression, interdiff and new patch attached.
Comment #42
c4rl CreditAttribution: c4rl commentedClosing tag needs to match.
Comment #43
joelpittetMay need the same tag for the ending tag(see the answer to the universe #42). But great work so far!
Comment #44
c4rl CreditAttribution: c4rl commentedHere's the fix for #42, though I haven't given the rest of this a good once-over. I'll post a further revision if I encounter anything else.
I also changed the proposed syntax a bit to be somewhat friendlier to novices.
Comment #45
gnugetduh! this is embarrassing, sorry.
New patch and interdiff attached.
Regards
Comment #46
c4rl CreditAttribution: c4rl commentedResetting status. Looks like gnuget and I cross-posted :)
We took a slightly different approach to how to determine the tag. It's a bit of a bikeshed I suppose; the only real indication of which is better I guess necessitates a performance review -- that is, does setting a variable in twig with a ternary take more time than calculating an existing if statement twice?
IMHO, the double if is more grokkable, so I might fire up apache bench to see if there's a clear winner.
Comment #48
gnuget#45: twig-table-1939008-44.patch queued for re-testing.
Comment #50
gnugetI don't understand why my patch fail the automatic tests :/
Comment #51
a.ross CreditAttribution: a.ross commentederrr, that test failure seems completely unrelated... awkward
Comment #52
gnuget#45: twig-table-1939008-44.patch queued for re-testing.
Comment #54
joelpittet@gnuget just whitespace issue. Added modifiers see interdiff.txt. Quite interested to see @c4rl's performance tests!
Comment #55
c4rl CreditAttribution: c4rl commentedOkay, so after some basic performance testing (building 100 3x3 tables on a given page callback, 100 requests via ab), the double-if approach acknowledged in #46 is about 3% slower. Let's stick with the cell_tag approach.
Comment #56
joelpittetThanks @c4rl! That is good to know, I'll try to keep my ifs down to a minimum, especially in the loops.
Comment #57
joelpittetCould someone give that nested for loop issue a go with this patch?
http://drupal.org/node/1867090#comment-7317014
Comment #58
joelpittetre-rolled as #1867090: Nested Twig 'for' loops behaving strange landed, and fixed some whitespace and redundancies in the twig template.
Comment #60
joelpittet#58: 1939008-58-theme-table.patch queued for re-testing.
Comment #60.0
joelpittetUpdate remaining, add testing steps
Comment #61
c4rl CreditAttribution: c4rl commentedComment #62
gnugetI added the missing test for check if the header option in cells works correctly.
Comment #63
steveoliver CreditAttribution: steveoliver commentedNice cleanup here.
I wonder about inlining that ternary for cell tag and losing the {% set?
Comment #64
c4rl CreditAttribution: c4rl commented@steveoliver #63, See #44, #46 and #55.
Comment #65
steveoliver CreditAttribution: steveoliver commentedah, yep. two tags. duh.
Comment #65.0
steveoliver CreditAttribution: steveoliver commentedAdd related issue
Comment #66
Bojhan CreditAttribution: Bojhan commentedWhats the ETA on this? Anything I can do to help
Comment #67
joelpittet@Bojhan This one is fairly dialed, but won't get committed until all the rest of twig conversions get in all at once. It couldn't hurt to do one more round of manual tests to make sure we didn't miss anything because it is one of the trickier conversions.
Comment #68
star-szr@Bojhan - a patch review would be great too :)
Comment #69
Wim LeersI don't know *anything* about Twig, so I'm not reviewing the correctness of the code. Instead, I'm reviewing code style and understandability.
Indented too far.
We never add comments for this sort of thing. This line can be removed.
We're approaching code freeze, nothing may be deferred to follow-ups — unless it's an independent change.
A similar check is at the beginning of the function. Weird.
AFAIK we always write "JavaScript", not "JS" in comments.
This is way too much repeated information.
Something like this should be sufficient:
"If the table is responsive, set a class and add the necessary library."
s/JS/JavaScript/
Again too much info, this line can be deleted.
Again excessive, delete.
s/or/and/
Excessive, remove.
Better comment needed.
Excessive, remove.
s/is set/is not empty/
See remark for earlier @todo
s/Build up/Build/
Third (!!!) time there's an if-test for this.
What's with all the blank lines?
Excessive, remove.
See previous @todo remarks.
Excessive, remove.
Again @todo.
Again excessive.
Missing trailing period.
Comment should be above the if-test.
Excessive, remove.
Similar code exists earlier, consider creating a helper function.
80 cols exceeded?
Excessive.
Trailing period.
Comment #70
drupalninja99 CreditAttribution: drupalninja99 commented@Wim Leers, I have made the edits you requested.
I will comment on the more notable changes:
I looked at the 2 blocks of code and I didn't see anything that lead me to believe that they couldn't be combined so I took the two conditionals and combined them.
I changed to "// Build colgroups and assign attributes"
Seems like a good @todo, I removed in the patch but do we need a new ticket for this or should we just move on?
I only counted 2 and I combined the two code blocks.
I looked through the code and $headers was only used once. I just removed the variable and replaced it's one usage with $variables['header'] which I think solves the @todo. $headers was really serving no purpose.
I did a char count and it was less than 80
I have not yet tested these changes.
Comment #72
joelpittet@drupalninja99 something's funky with your interdiff format it won't apply and dreditor doesn't syntax highlight it. Also, #62 Needed a re-roll first so that may be why your patch isn't applying.
Here is the reroll from #62
I'll try to get your patch on top of it or do an interdiff between the branches at the least.
Comment #73
joelpittetOk yeah, had to roll back to apply your patch @drupalninja99, commit it and rebase forward.
Attached is the interdiff between #72 and your patch re-rolled.
Comment #74
joelpittetHere is some further cleanup:
Comment #75
joelpittet@drupalninja99 thank you very much for the patch btw!
Tagging
Comment #76
joelpittetSeems like these may not be good enough? But there is quite a few more function calls, so maybe some refactoring could happen?
Scenario 1
/admin/people/permissions, stark
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51b0309e0d24b&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51b0309e0d24b&...
Scenario 2
/admin/modules, stark
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51b032b631491&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51b032b631491&...
Comment #77
drupalninja99 CreditAttribution: drupalninja99 commentedIs this just profiling the patched files against 8.x HEAD?
Comment #78
joelpittet@drupalninja99 yes, it's theme_table vs table.html.twig battle royal.
Comment #79
drupalninja99 CreditAttribution: drupalninja99 commentedI had to re-create patch #74 because it wouldn't apply to head as of 15 minutes ago. I think I was able to get it reapplied to head just now.
Comment #80
joelpittet#79 @drupalninja99 I just applied #74 with no problems.
Again, something wrong with your interdiffs. Jump on IRC so we can discuss your workflow.
Comment #81
joelpittetYou may not use IRC, so the channel is #drupal-twig if you decide to join.
In the meantime:
Your changes go here.
Comment #82
joelpittetIt'd be good for me to know how you got that strange interdiff though your patch seems to be the right format.
Comment #83
drupalninja99 CreditAttribution: drupalninja99 commentedHi Joel, sorry I was just doing a lazy diff btwn patches. I am new to Drupal patches. You workflow makes sense, I will start doing that from now on.
Comment #84
drupalninja99 CreditAttribution: drupalninja99 commentedMy analysis of the profiling report is that the underlying Twig calls/inefficiency are what's causing the WT increase. The Attribute method/object is getting called a ton and so if we can fix any efficiencies there (already have a ticket for this) then we should be fine. I didn't see anything in template_preprocess_table that would be low hanging fruit as far as general refactoring goes.
Also another note, do we need to replace all doc references to "theme_table()" with template_preprocess_table()? I saw 9 references to theme_table() just in the /core/includes folder. Since there is no more theme_table I would think we'd want to refer people to template_preprocess_table().
Comment #85
star-szrPatch in #79 no longer applies, needs to be rerolled.
Comment #86
joelpittetRe-rolled. Already profiled in #76
Comment #87
star-szrThanks @drupalninja99 and @joelpittet for keeping this going :) Patch no longer applies, needs a reroll.
Comment #88
joelpittetRe-roll and remove @see template_preprocess() from twig template.
Comment #89
joelpittetBot! go
Comment #90
joelpittetRe-roll and also note it would be really nice to have forum as #type table so the @todo from here for the forum table headers can be removed from this patch.
Comment #91
joelpittet#1938906: Convert forum theme tables to table #type Re-opened the #type table issue because it still needs to be done.
Comment #93
joelpittetMade a followup issue to remove _theme_table_cell from forum.
@see #2092343: Consolidate forum.module and remove call to _theme_table_cell() within template_preprocess_forum_topic_list()
Also re-closed that #type=>table for forum which I thought would be a good fix to that but it was tricky and possibly not worth the effort.
This issue is blocked on that new issue so we can remove _theme_table_cell() as we have in this patch and to keep this issue as a conversion patch as it's big enough as it is.
I'm assigning this to me to fix those two errors and remove the _theme_table_cell removal from this patch. Something to do on the plane.
Comment #93.0
joelpittetRemove sandbox link
Comment #94
joelpittetWell unpostponing because that little quick issue got taken over and became more complicated. Here's a re-roll.
Comment #97
joelpittet94: 1939008-94-theme-table.patch queued for re-testing.
Comment #98
joelpittetRemoved and simplify tablesort_cell as a micro-optimization and remove the zebra for zoo todo.
Comment #100
joelpittetLatest profiling of Scenario 1 from #76
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52c2677cc22b0&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52c2677cc22b0&...
Comment #101
star-szrTagging for reroll.
Comment #102
longwaveRerolled.
Comment #103
dawehnerIn general I think that 3% overhead for tables is not bad. Most tables are rendered on the admin backend and never on the frontend.
It is impressive how much logic we need to render a table :(
Can we get rid of the direct call to drupal_add_library?
Comment #104
joelpittetOk it's mildly better now that twig 1.15 is in there. 2.7% slower instead of 3-3.3% slower.
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52ed72044139b&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52ed72044139b&...
@dawehner yes it was quite a challenging conversion. I'll convert those to #library.
Comment #105
joelpittet@dawehner seems that it's awkward to do the #attached thing in theme functions... there may be a solution in place in #2171071: Rename drupal_add_library() to _drupal_add_library() and remove its uses which is critical and will cause this to be re-rolled as soon as it's in so I'll wait on that.
Comment #106
star-szrComment #107
joelpittetThis is a re-roll because #2092343: Consolidate forum.module and remove call to _theme_table_cell() within template_preprocess_forum_topic_list() is now in and doesn't need to be part of this conversion.
Comment #109
joelpittet107: 1939008-theme-table-107.patch queued for re-testing.
Comment #110
joelpittetReviewing my own patch:D I'll post the changes soon. I'm glad a bit of the forum stuff is out of this. Considering moving the tablesort_cell and _theme_table_cell out to their own cleanup patches so lighten this patch up a bit more... thoughts?
This move cell properties needs to happen first or it will clobber the sort attributes. Swap the blocks around.
This could use a test.
This isn't needed here.(leftover)
use drupal_render() instead of theme() because theme calls are being deprecated.
Remove @todo, we aren't deprecating it.
Comment #111
RainbowArrayHere is a patch with all of the changes joelpittet suggested above, except for the addition of the test in item 2, which he said he would post separately, possibly a sub-issue.
Comment #112
joelpittetif only they were the same like that.
drupal_render()
takes a renderable array with all the keys as #.so
drupal_render(array('#theme' => 'table', '#header' => $header, ... etc.));
Everything else looks good:)
Comment #114
RainbowArrayThis should fix the issue with the drupal_render arrays, along with the previous fixes. Interdiff provided too.
Comment #116
joelpittet@mdrummond sorry my bad you can't pass in an array directly because it's a referenced value. I always forget that until I run the tests.
Here's the fix and also I made sure the xpath is a bit closer to what it was. before that conversion.
Comment #117
RainbowArraySince the tests are passing, what's next with this conversion?
Comment #118
joelpittetNeeds a bit more manual tests. You could get the tables from here and put them in a controller or preprocess to get them rendering (module is really out of date but table render arrays should still be good).
https://github.com/joelpittet/twig-tables
And if the manual testing goes well enough then maybe RTBC?
Comment #119
sphism CreditAttribution: sphism commentedI'm taking a look at this now
Comment #120
sphism CreditAttribution: sphism commentedOk, so the twig tables module didn't work for me, i added the correct .info.yml file but still says page not found on /twig-tables - i think because it needs a routing.yml file ???
But i added the example table render array to bartik_preprocess_page, then printed my new variable in page.html.twig
here's the source code
And i've attached a screen shot (Mac chrome)
When i went to apply the most recent patch it didn't apply...
error: patch failed: core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php:27
Comment #121
joelpittetreroll
Comment #122
sphism CreditAttribution: sphism commentedok i've applied the patch from #121 and have made a screengrab, and copied the source, and diffed the original output to patched output.
However it's really hard to see what's going on because the formatting is very different
So I reformatted both the source code outputs, put everything onto separate lines, removed all whitespace, diffed the 2... and they are 100% identical, which leaves to one of 2 conclusions, either this patch is perfect, or I did something wrong and i'm comparing the same thing twice.
I've attached all my files, see what you think
Comment #123
gokulnk CreditAttribution: gokulnk commentedThe patch was not applying.
I am adding the Re-roll.
Comment #125
jessebeach CreditAttribution: jessebeach commented#2171071: Rename drupal_add_library() to _drupal_add_library() and remove its uses was committed.
Please note that the responsive and sticky header libraries are added in
drupal_pre_render_table
now. We should no longer call_drupal_add_library
in theme functions.Thanks!
Comment #126
joelpittetI'm postponing this again on #2216407: Remove _theme_table_cell(). which splits out the removal of _theme_table_cell and tablesort_cell. As well as the header test addition.
Hope this makes this patch easier to read after that is in.
Comment #127
sunWasn't there support for multiple TBODYs at some point?
Or am I misguided and that feature is not in core yet...?
Comment #128
joelpittet@sun re #127 not in D7 or D8 yet there hasn't been that feature. Though at issue is really old and over here #31535: Allow table row groups in table.html.twig and template_preprocess_table()
Comment #129
sunComment #130
joelpittet@sun awesome, thanks for taking a look at this! All the changes look great, just some minor notes below.
I really like the
{{ cell.tag }}
change:)removeWhitespace
andrender
methods onto the base class? And just curious were they nessasary to get things working?Might as well put a period at the end of this sentance as well.
Needs a .
The indentation of the template was following the coding standards.
The template readability is a bit more important than the HTML output indenting, IMO. @see bottom of http://twig.sensiolabs.org/doc/coding_standards.html
and @see https://drupal.org/node/1823416
Comment #131
sunTableTest
can and should be moved/merged into that new concept later on. But laters.Comment #133
sunFixed NodeTypeRenameConfigImportTest relies on exact HTML markup.
Comment #134
joelpittetI've created a follow up to clean up doc standards. #2256595: Clean up remaining doc standards in template_preprocess_table() after it's converted to twig template.
I think this is now RTBC. Thanks for your work on it @sun! If someone else needs to take a look at it that's cool but it's been around for a while now. Lots of eyes coming and going and was previously in the twig sandbox.
Added commit message to IS with people from the sandbox added.
Comment #135
sunJust FYI: Due to the test code in this + some other issues, I worked on enabling native support for rendered content assertions in DUTB tests:
#2257519: Move content assertion methods into a trait, so DUTB can consume it, too
The changes of that issue will cause conflicts with this patch, so whichever lands first will require the other to be re-rolled. If the other lands first, then the
removeWhitespace()
method from this patch here should be moved into the newAssertContentTrait
.Comment #136
webchickThis is such an unbelievably huge improvement over the status quo (which afaics requires like 11 years of experience in PHP debugging to theme a table) I can't even explain. :) Great work.
This seems generally useful (if a bit terrifying ;)), so why is it in NodeTypeRenameConfigImportTest.php and not in a test base class somewhere?
Can the docs also be expanded slightly to explain a short sentence on why someone might want to use this helper? I can't quite figure it out. Which leads to...
No idea what these tests are testing. :( We need a comment here.
Hm. That looks wrong. How/where is the translation being handled, if not here? Or are you only doing this because it's in a test and tests won't be translated?
Comment #137
webchickIssue #1939008 by sun,,, Cottser, drupalninja99, mdrummond, sphism, c4rl,, andypost, Fabianx, Gokul N K, longwave | jenlampton: Convert theme_table() to Twig.
Ok, Joel and I spent another hour or so on this patch and came to the following conclusions:
- The unrelated t() removal is indeed because they're in test files which are not translated.
- The reason we need to move from assertText() to assertTextPattern() is because the config UI's diff output now puts the "-" and the "thing" on two separate lines, which assertText() can't deal with. Added a comment to that effect.
- I still think assertTextPattern() is needs a) some clarification as to its purpose a) to be moved to a test base class, and/or c) the changes made "upstream" in the WebTestBase method. But I don't think it's worth holding up this important twig patch just because sun decided to be fancy. ;) But opened a follow-up here: #2257945: Move NodeTypeRenameConfigImportTest::assertTextPattern() to AssertContentTrait
Given that the "meat" of this still looks nice and solid, going to go ahead and get 'er done.
Committed and pushed to 8.x. Thanks! GREAT work, everyone!
Comment #139
Mile23SRSLY needs a change record. :-)
Comment #140
joelpittet@Mile23 We discussed this briefly at last weeks Thursday twig hangout. Which is recorded and on youtube https://www.youtube.com/watch?v=sj8BxZLhVb4&list=UUhHSH9ZDWsfpHrhYLam8qIg. Gah I hate hearing my voice.
It's a bit strange to do conversion issues as we've done so many and the main goal behind them to keep the same API(if the API does change we provided change records) and convert the theme_* functions that provides HTML output to the *.html.twig template that provides the same output. We even diligently compare markup to make sure that hasn't change either before RTBC.
Comment #141
sunI agree - that's a much larger scope, and it doesn't make any sense to create one-off change notices for every single theme function that is converted to a Twig template. A (really long) list of individual change notices would not help anyone at all.
Let's figure that out in a separate issue — also, I can't imagine that this is the first time the question comes up, so I can only assume that there must be an issue already.
Comment #142
joelpittetIt is the first time I've seen it come up and @webchick asked me about it last weekend that's why it ended up the meeting.
@Mile23 I'd recommend just adding a "Needs change record" tag #1757550: [Meta] Convert core theme functions to Twig templates and making any further recommendations on what the draft should say. And maybe start a draft CR of what you think it should say.