Created
February 17, 2011 21:58
-
-
Save thecodejunkie/832817 to your computer and use it in GitHub Desktop.
Uses <TModel> to convert the call from dynamic to TModel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ViewEngineResult RenderView<TModel>(string path, TModel model) | |
{ | |
var viewName = | |
Path.GetFileNameWithoutExtension(path); | |
var viewPath = | |
Path.GetDirectoryName(path); | |
var targetNamespace = string.Empty; //TODO Rob G: This can be used to support things like areas or features | |
this.ViewFolder = new FileSystemViewFolder(viewPath); | |
HttpContextBase httpContext = null; //TODO Rob G: figure out how to get httpcontext passed in so that we can support view and partial caching. | |
var actionContext = new ActionContext(httpContext, targetNamespace); | |
var result = FindView(actionContext, viewName, null); | |
var viewWithModel = result.View as NancySparkView<TModel>; | |
if (viewWithModel != null) | |
{ | |
viewWithModel.SetModel(model); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment