private IFubuRazorView getPartialView(IFubuRazorView view, string name) { var template = _sharedTemplateLocator.LocatePartial(name, view.OriginTemplate); var partialView = _templateFactory.GetView(template.Descriptor.As <ViewDescriptor <IRazorTemplate> >()); return(partialView); }
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())); }
public override IFubuRazorView Modify(IFubuRazorView view) { var temporary = view; while (temporary != null) { temporary.RenderPartialWith = name => { var template = _locator.LocatePartial(name, view.OriginTemplate); var partialView = _templateService.GetView(template.Descriptor.As <ViewDescriptor <IRazorTemplate> >()); var modifier = view.Get <IViewModifierService <IFubuRazorView> >(); partialView = modifier.Modify(partialView); var partialRendered = partialView.Run(new ExecuteContext()); return(new TemplateWriter(x => x.Write(partialRendered))); }; temporary = temporary.Layout.As <IFubuRazorView>(); } return(view); }