-
-
Save timgthomas/05ffe58306e360905863 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
[ChildActionOnly] | |
public string GetRequireJSUrl(ViewContext context) | |
{ | |
var values = context.RouteData.Values; | |
var controller = values["controller"].ToString().ToLower(); | |
var viewContext = (RazorView)context.View; | |
var viewName = Path.GetFileNameWithoutExtension(viewContext.ViewPath); | |
var requirePath = VirtualPathUtility.ToAbsolute("~/Content/js/lib/require-2.1.6.js"); | |
var loc = string.Format("~/Features/{0}/{1}.js", controller, viewName); | |
if (System.IO.File.Exists(Server.MapPath(loc))) | |
{ | |
return "<script data-main='" + VirtualPathUtility.ToAbsolute(loc) + "' src='" + requirePath + "'></script>"; | |
} | |
// If we don't have a custom Require module, use the default (optional). | |
return "<script data-main='" + VirtualPathUtility.ToAbsolute("~/Features/Shared/Default.js") + "' src='" + requirePath + "'></script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment