Refactor code that gathers and generates HTML out of ControllerExtension and into its own class.