CMS-4027 Refactor thymeleaf for better JS support.