Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Oct 14, 2013
2 parents 487773d + afe4113 commit fb0c100
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The RequireJS for .NET project smoothly integrates the RequireJS framework with

### Documentation

* [Setup RequireJS for ASP.NET MVC using NuGet](http://www.stefanprodan.eu/2013/08/setup-requirejs-for-asp-net-mvc-using-nuget/)
* [Setup and configuration](https://github.com/stefanprodan/RequireJSDotNet/wiki/RequireJS-for-.NET-setup)
* [Programming guide](https://github.com/stefanprodan/RequireJSDotNet/wiki/Programming-with-RequireJS-for-.NET)

Expand Down
13 changes: 9 additions & 4 deletions RequireJsNet/RequireJsHtmlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
: "Root";
var controller = html.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue as string;
var action = html.ViewContext.Controller.ValueProvider.GetValue("action").RawValue as string;

var entryPoint = "Controllers/" + area + "/" + controller + "/" + controller + "-" + action;
var entryPointTmpl = "Controllers/{0}/" + controller + "/" + controller + "-" + action;
var entryPoint = string.Format(entryPointTmpl, area);
var filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");

return File.Exists(filePath) ? new MvcHtmlString(entryPoint) : null;
if (File.Exists(filePath))
{
return new MvcHtmlString(entryPoint);
}
entryPoint = string.Format(entryPointTmpl, "Common");
var fallbackFile = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");
return File.Exists(fallbackFile) ? new MvcHtmlString(entryPoint) : null;
}

public static MvcHtmlString GetRequireJsPaths(this HtmlHelper html, string configPath = "")
Expand Down

0 comments on commit fb0c100

Please sign in to comment.