I need to create a list of items in SXA with a background defined by the items themselves. On the items, the editor can select a colour (droplist). On the display, I want to use that colour as the background of that items tile.
I know that I can set css classes on the variants, but then they are fixed by the variant definition. I also know I can get fields from the item, but then they are just displayed and not in the class of a div or section.
I tried using a NVelocity template to open a div with the css class in it, but apparently SXA is too clever and closes the div for me (so the rest of my data is not in but after the div).
I considered using the rules engine to enable or disable part of the variant definition. But that seems weird, because I think I would need to create a variant section (including all needed children) for each possible colour.