Created
April 11, 2013 21:00
-
-
Save johncoder/5367111 to your computer and use it in GitHub Desktop.
This file contains 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
public class StaticViewEngine : VirtualPathProviderViewEngine | |
{ | |
public StaticViewEngine() | |
{ | |
MasterLocationFormats = new string[] { | |
}; | |
ViewLocationFormats = new[] { | |
"~/build/templates/{1}/{0}.html", | |
"~/build/templates/{0}.html", | |
"~/build/{1}/{0}.html", | |
"~/build/{0}.html", | |
"~/Views/{1}/{0}.html", | |
"~/Views/Shared/{0}.html" | |
}; | |
PartialViewLocationFormats = ViewLocationFormats; | |
} | |
protected override IView CreatePartialView(ControllerContext controllerContext, | |
string partialPath) { | |
return new StaticView(partialPath); | |
} | |
protected override IView CreateView(ControllerContext controllerContext, | |
string viewPath, | |
string masterPath) { | |
return new StaticView(viewPath); | |
} | |
} | |
public class StaticView : IView | |
{ | |
private string _viewPath; | |
public StaticView(string viewPath) | |
{ | |
_viewPath = viewPath; | |
} | |
public void Render(ViewContext viewContext, System.IO.TextWriter writer) | |
{ | |
viewContext.HttpContext.Response.WriteFile(_viewPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment