Skip to content

Instantly share code, notes, and snippets.

@thecodejunkie
Created February 17, 2011 21:58
Show Gist options
  • Save thecodejunkie/832817 to your computer and use it in GitHub Desktop.
Save thecodejunkie/832817 to your computer and use it in GitHub Desktop.
Uses <TModel> to convert the call from dynamic to TModel
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