Files
Disco/Disco.Web/T4MVC.tt.hooks.t4
T
2013-02-01 12:35:28 +11:00

44 lines
1.6 KiB
Plaintext

<#+
/*
This file contains hooks and extra code 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.
*/
static bool AddTimestampToStaticLink(ProjectItem projectItem) {
// By default, this just returns the static flag, but you can add additional logic to make more complex
// decisions about which files should have the timestamp
// See http://mvccontrib.codeplex.com/workitem/7129 for details
return settings.AddTimestampToStaticLinks;
}
void RenderAdditionalCode() {
#>
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public 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);
}
}
<#+
}
#>