From 4b3c5257c71819506b9dd88d994cbea271c64ab8 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sat, 7 Sep 2013 11:16:45 +0300 Subject: [PATCH 1/2] NuGet --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eb211d4..b634dc0 100644 --- a/README.md +++ b/README.md @@ -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) From bd3d189cee1295680108ee82d4196ee1b5ddfe49 Mon Sep 17 00:00:00 2001 From: cristipufu Date: Fri, 4 Oct 2013 13:08:44 +0300 Subject: [PATCH 2/2] fallback to area common if entry point not found, search in area common --- RequireJsNet/RequireJsHtmlHelpers.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/RequireJsNet/RequireJsHtmlHelpers.cs b/RequireJsNet/RequireJsHtmlHelpers.cs index b890a2c..9f51a13 100644 --- a/RequireJsNet/RequireJsHtmlHelpers.cs +++ b/RequireJsNet/RequireJsHtmlHelpers.cs @@ -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)