I've been writing some code to attempt to enable MVC Razor-style view compilation and execution with RazorEngine but ran into a big snag with the way that TemplateService.Parse() works.
MVC allows obtaining the instantiated compiled class object prior to calling Execute() to do the rendering so that it can provide some necessary data to the base class of the template (e.g. ViewData).
The current design of RazorEngine does not provide a way to configure additional information on the object instance before Execute() is called. Would it be possible to add in hooks prior to Execute() for doing our own thing with the object?
public string Parse(string template, string name = null)
var instance = GetTemplate(template, null, name);
I had considered whether it might be possible to hook an IActivator instance into a DI container to use setter injection or something to create the instances with injected dependencies, but might be nice to just have something directly in the design to do
Has anyone else been successful in creating a WebViewPage-like template base class so that you can execute Html helpers, etc. using code compatible with MVC razor views? That's ultimately what I'd want.