add .html_safe and fixed template formatting