I wrote some templates based on JS, but Anki render those only once. So, for example, my template appends to to word and changes the color of the page. It’s fine until you use Show Answer button, to disappears. And if continue to second car, there are no anymore to and custom color (the color stays from previous the first card).
Can reproduce it in Windows 11 (qt5 and qt6) and AnkiWeb, but not in AnkiDroid.