I've noticed this when I used the following in my view:
<% Html.RenderPartial(MVC.Shared.Views.EditorTemplates.ClientOnDocuments); %>
The line above returns just the name of the view, so in this case ClientOnDocuments
. The default view engine then kicks in and tries to find ClientOnDocuments.ascx
in the current view's folder and in the Shared folder but not in DisplayTemplates
and EditorTemplates
folder.
Since I've gone pretty far with my use of T4MVC I don't want to dump it or mix different styles of referencing views (for instance, the above works if we provide the path to the template).
The reason lies in this code that T4MVC generates:
public class ViewNames {
...
public readonly string FirmHeader = "~/Views/Shared/FirmHeader.ascx";
public readonly string PostsSelector = "~/Views/Shared/PostsSelector.ascx";
static readonly _DisplayTemplates s_DisplayTemplates = new _DisplayTemplates();
public _DisplayTemplates DisplayTemplates { get { return s_DisplayTemplates; } }
public partial class _DisplayTemplates{
public readonly string ClientOnDocuments = "ClientOnDocuments";
public readonly string DateTime = "DateTime";
}
static readonly _EditorTemplates s_EditorTemplates = new _EditorTemplates();
public _EditorTemplates EditorTemplates { get { return s_EditorTemplates; } }
public partial class _EditorTemplates{
public readonly string ClientOnDocuments = "ClientOnDocuments";
public readonly string DateTime = "DateTime";
public readonly string PostCode = "PostCode";
}
You can see that with the view contained in Shared root everything is fine but apparently it doesn't handle subfolders well.
I know I could change the T4MVC template file but would actually like a response from David Ebbo on whether he is going to change/correct this.
Hopefully he follows SO, at least I saw him here in December.