Skip to content

Commit

Permalink
Merge pull request #1 from cristipufu/master
Browse files Browse the repository at this point in the history
fallback to area common
  • Loading branch information
stefanprodan committed Oct 4, 2013
2 parents 4b3c525 + bd3d189 commit afe4113
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions RequireJsNet/RequireJsHtmlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,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)
Expand Down

0 comments on commit afe4113

Please sign in to comment.