Skip to content

Instantly share code, notes, and snippets.

@cwe1ss
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwe1ss/970c65995280496a1864 to your computer and use it in GitHub Desktop.
Save cwe1ss/970c65995280496a1864 to your computer and use it in GitHub Desktop.
Custom ViewEngine for the "Feature Folder" project structure
public class FeatureFolderViewEngine : RazorViewEngine
{
public FeatureFolderViewEngine()
{
// {0} ActionName
// {1} ControllerName
// {2} AreaName
AreaViewLocationFormats = new[]
{
"~/Areas/{2}/{1}/{0}.cshtml",
"~/Areas/{2}/Shared/{0}.cshtml",
"~/Areas/Shared/{0}.cshtml",
};
AreaMasterLocationFormats = new[]
{
"~/Areas/{2}/{1}/{0}.cshtml",
"~/Areas/{2}/Shared/{0}.cshtml",
"~/Areas/Shared/{0}.cshtml",
};
AreaPartialViewLocationFormats = new[]
{
"~/Areas/{2}/{1}/{0}.cshtml",
"~/Areas/{2}/Shared/{0}.cshtml",
"~/Areas/Shared/{0}.cshtml",
};
ViewLocationFormats = new[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/Shared/{0}.cshtml",
};
MasterLocationFormats = new[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/Shared/{0}.cshtml",
};
PartialViewLocationFormats = new[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/Shared/{0}.cshtml",
};
FileExtensions = new[]
{
"cshtml",
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment