-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT4MVC.settings.t4
112 lines (85 loc) · 4.44 KB
/
T4MVC.settings.t4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<#+
/*
This file contains settings used by T4MVC.tt. The main goal is to avoid the need for users
to fork the 'official' template in order to achieve what they want.
*/
// The prefix used for things like MVC.Dinners.Name and MVC.Dinners.Delete(Model.DinnerID)
const string HelpersPrefix = "MVC";
// Namespaces to be referenced by the generated code
readonly string[] ReferencedNamespaces = new string[] {
};
// The folder under the project that contains the areas
const string AreasFolder = "Areas";
// Choose whether you want to include an 'Areas' token when referring to areas.
// e.g. Assume the Area is called Blog and the Controller is Post:
// - When false use MVC.Blog.Post.etc...
// - When true use MVC.Areas.Blog.Post.etc...
static bool IncludeAreasToken = false;
// The folder under the project that contains the controllers
const string ControllersFolder = "Controllers";
// The folder under the project that contains the views
const string ViewsRootFolder = "Views";
// Views in DisplayTemplates and EditorTemplates folders shouldn't be fully qualifed as it breaks
// the templated helper code
readonly string[] NonQualifiedViewFolders = new string[] {
"DisplayTemplates",
"EditorTemplates"
};
// The name of the interface that all T4MVC action results will implement
const string ActionResultInterfaceName = "IT4MVCActionResult";
// If true, the T4MVC action result interface will be generated
// If false, the namespace of the interface must be referenced in the 'ReferencedNamespaces' setting
static bool GenerateActionResultInterface = true;
// If true, use lower case tokens in routes for the area, controller and action names
static bool UseLowercaseRoutes = false;
// The namespace that the links are generated in (e.g. "Links", as in Links.Content.nerd_jpg)
const string LinksNamespace = "Links";
// If true, links to static files include a query string containing the file's last change time. This way,
// when the static file changes, the link changes and guarantees that the client will re-request the resource.
// e.g. when true, the link looks like: "/Content/nerd.jpg?2009-09-04T12:25:48"
static bool AddTimestampToStaticLinks = true;
// Folders containing static files for which links are generated (e.g. Links.Scripts.Map_js)
readonly string[] StaticFilesFolders = new string[] {
"Scripts",
"Content",
};
// Static files to exclude from the generated links
readonly string[] ExcludedStaticFileExtensions = new string[] {
".cs"
};
//---------------------------------------------------------------------------
// Explicit HtmlHelpers
//---------------------------------------------------------------------------
//create explicit HtmlHelpers for rendering partials
static bool ExplicitHtmlHelpersForPartials = false;
const string ExplicitHtmlHelpersForPartialsFormat = "Render{0}";
//---------------------------------------------------------------------------
// If true, the template marks itself as unsaved as part of its execution.
// This way it will be saved and update itself next time the project is built.
// Basically, it keeps marking itself as unsaved to make the next build work.
// Note: this is certainly hacky, but is the best I could come up with so far.
static bool AlwaysKeepTemplateDirty = false;
// If true,the template output will be split into multiple files.
static bool SplitIntoMultipleFiles = false;
void RenderAdditionalCode() {
#>
static class T4MVCHelpers {
// You can change the ProcessVirtualPath method to modify the path that gets returned to the client.
// e.g. you can prepend a domain, or append a query string:
// return "http://localhost" + path + "?foo=bar";
private static string ProcessVirtualPathDefault(string virtualPath) {
// The path that comes in starts with ~/ and must first be made absolute
string path = VirtualPathUtility.ToAbsolute(virtualPath);
// Add your own modifications here before returning the path
return path;
}
// Calling ProcessVirtualPath through delegate to allow it to be replaced for unit testing
public static Func<string, string> ProcessVirtualPath = ProcessVirtualPathDefault;
// Logic to determine if the app is running in production or dev environment
public static bool IsProduction() {
return (HttpContext.Current != null && !HttpContext.Current.IsDebuggingEnabled);
}
}
<#+
}
#>