TemplateParser: encode branch values using PHP's own serializer