Thread:Extension talk:Capiunto/Row-styling function

We had a discussion on the enwiki Template:Infobox talk page a while back about having different styles for odd- and even-numbered headers in infoboxes. At the moment this happens in en:Template:Infobox baseball biography, for example in the en:Ichiro Suzuki article, which alternates the colour of the header cells between each of Ichiro's two team colours. At the moment it does this by using a horrible hack; each second header in the infobox is in fact a child infobox with the headerstyle set to the team's secondary colour. It would be nice to be able to specify conditional styles for rows or headers so that we can do away with hacks like this.

Different infoboxes will have different requirements for conditional styling, though. One infobox might require every even-numbered header to be a certain colour, and another might require every second data row after a header to be a certain colour. Because of this, I think the functionality may be best implemented as a function that can be passed to the infobox object. It would take a few different parameters as input: the row number, the header number, isHeader, and the number of rows since the last header. And as output, it could produce a table that would then be passed to mw.html:css. Is this idea workable?