I've messed around with Simple.Web.Razor a little bit and applied the following changes:
- Made both Handler and Model properties public to get in SimpleTemplateBase
- Created a HtmlHelper class with a string returning Partial(string viewPath) method that is as follows:
public string Partial(string viewPath)
{
Type partialViewType = new RazorViews().GetViewType(viewPath);
var instance = (SimpleTemplateBase)Activator.CreateInstance(partialViewType);
// Make the partial view inherit both the model and the handler
instance.SetHandler(ParentView.Handler);
instance.SetModel(ParentView.Model);
instance.Render();
// Return the output
return instance.Output;
}
- Added a public instance of HtmlHelper to SimpleTemplateBase. A property called Html that instantiates HtmlHelper passing it the view itself (this).
After this, Html.Partial seems to be working. I don't really know if this implementation is in your plans or if it is already implemented somehow, but I could certainly adapt my code to your guidelines and contribute, if you wish.
Also, it would be nice to be able to change the base class for views. Is this possible or in your plans?
Thank you,
Marcelo.