added instanceof check to cast Twig_Markup objects to string