private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates)
        {
            var descriptor = new ViewDescriptor<IRazorTemplate>(template);
            var current = descriptor;
            for (var i = 0; i < templates.Length; ++i)
            {
                var layoutTemplate = templates[i];
                var layout = new ViewDescriptor<IRazorTemplate>(layoutTemplate);
                layoutTemplate.Descriptor = layout;
                current.Master = templates[i];
                current = layout;
            }

            var modifier = new ViewModifierService<IFubuRazorView>(Enumerable.Empty<IViewModifier<IFubuRazorView>>());
            var viewFactory = new ViewFactory(descriptor, _templateService, modifier);
            var view = (IFubuRazorView)viewFactory.GetView();
            view.ServiceLocator = _serviceLocator;
            view.RenderPartialWith = name =>
            {
                var partialTemplate = _sharedTemplateLocator.LocatePartial(name, view.OriginTemplate);
                partialTemplate.Descriptor = new ViewDescriptor<IRazorTemplate>(partialTemplate);
                var partialView =
                    _templateService.GetView(partialTemplate.Descriptor.As<ViewDescriptor<IRazorTemplate>>());

                var partialRendered = partialView.Run(new ExecuteContext());
                return new TemplateWriter(x => x.Write(partialRendered));
            };
            return view.Run(new ExecuteContext());
        }
        private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates)
        {
            var descriptor = new ViewDescriptor<IRazorTemplate>(template);
            var current = descriptor;
            for (var i = 0; i < templates.Length; ++i)
            {
                var layoutTemplate = templates[i];
                var layout = new ViewDescriptor<IRazorTemplate>(layoutTemplate);
                layoutTemplate.Descriptor = layout;
                current.Master = templates[i];
                current = layout;
            }

            var modifier = new ViewModifierService<IFubuRazorView>(Enumerable.Empty<IViewModifier<IFubuRazorView>>());
            var viewFactory = new ViewFactory(descriptor, _templateFactory, modifier);
            var view = (IFubuRazorView)viewFactory.GetView();
            view.ServiceLocator = _serviceLocator;
            view.As<IRenderableView>().Render();
            return view.Result.ToString();
        }