I get goosebumps (not in the good way) when I read this code. It feels fishy to modify rendered HTML in a controller. We might want to return JSON to the Client, who can build its DOM themselves.