Moving html result generation to template