diff --git a/RequireJsNet.Docs/Views/Shared/_Layout.cshtml b/RequireJsNet.Docs/Views/Shared/_Layout.cshtml
index c398060..898005f 100644
--- a/RequireJsNet.Docs/Views/Shared/_Layout.cshtml
+++ b/RequireJsNet.Docs/Views/Shared/_Layout.cshtml
@@ -56,7 +56,8 @@
{
"~/RequireJS.shared.config",
"~/RequireJS.config"
- })
+ },
+ entryPointRoot: "~/Scripts/")
}
else
{
diff --git a/RequireJsNet/RequireJsHtmlHelpers.cs b/RequireJsNet/RequireJsHtmlHelpers.cs
index 861439d..63ebfc3 100644
--- a/RequireJsNet/RequireJsHtmlHelpers.cs
+++ b/RequireJsNet/RequireJsHtmlHelpers.cs
@@ -26,44 +26,48 @@ namespace RequireJS
public static class RequireJsHtmlHelpers
{
const string DefaultConfigPath = "~/RequireJS.config";
+
///
/// Setup RequireJS to be used in layouts
///
///
/// @Html.RenderRequireJsSetup(Url.Content("~/Scripts"), Url.Content("~/Scripts/require.js"), "~/RequireJS.release.config")
///
- /// Scrips folder
+ /// scripts base url
/// requirejs.js url
/// RequireJS.config server local path
+ /// Scrips folder relative path ex. ~/Scripts/
public static MvcHtmlString RenderRequireJsSetup(this HtmlHelper html, string baseUrl, string requireUrl, string urlArgs = "",
- string configPath = "", IRequireJsLogger logger = null)
+ string configPath = "", string entryPointRoot = "~/Scripts/", IRequireJsLogger logger = null)
{
- return html.RenderRequireJsSetup(baseUrl, requireUrl, urlArgs, new List { configPath }, logger);
+ return html.RenderRequireJsSetup(baseUrl, requireUrl, urlArgs, new List { configPath }, entryPointRoot, logger);
}
///
/// Setup RequireJS to be used in layouts
///
- /// Scrips folder
+ /// scripts base url
/// requirejs.js url
/// RequireJS.config files path
+ /// Scrips folder relative path ex. ~/Scripts/
public static MvcHtmlString RenderRequireJsSetup(this HtmlHelper html, string baseUrl, string requireUrl,
- IList configsList, IRequireJsLogger logger = null)
+ IList configsList, string entryPointRoot = "~/Scripts/", IRequireJsLogger logger = null)
{
- return html.RenderRequireJsSetup(baseUrl, requireUrl, null, configsList, logger);
+ return html.RenderRequireJsSetup(baseUrl, requireUrl, null, configsList, entryPointRoot, logger);
}
///
/// Setup RequireJS to be used in layouts
///
- /// Scrips folder
+ /// scripts base url
/// requirejs.js url
///
/// RequireJS.config files path
+ /// Scrips folder relative path ex. ~/Scripts/
public static MvcHtmlString RenderRequireJsSetup(this HtmlHelper html, string baseUrl, string requireUrl, string urlArgs,
- IList configsList, IRequireJsLogger logger = null)
+ IList configsList, string entryPointRoot = "~/Scripts/", IRequireJsLogger logger = null)
{
- var entryPointPath = html.RequireJsEntryPoint();
+ var entryPointPath = html.RequireJsEntryPoint(entryPointRoot);
if (entryPointPath == null)
{
@@ -116,14 +120,18 @@ public static MvcHtmlString RenderRequireJsSetup(this HtmlHelper html, string ba
return new MvcHtmlString(configBuilder.Render() + requireRootBuilder.Render());
}
- public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
+ ///
+ /// Returns entry point script relative path
+ ///
+ /// Relative root path ex. ~/Scripts/
+ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html, string root)
{
var routingInfo = html.GetRoutingInfo();
//search for controller/action.js in current area
var entryPointTmpl = "Controllers/{0}/" + routingInfo.Controller + "/" + routingInfo.Action;
var entryPoint = string.Format(entryPointTmpl, routingInfo.Area);
- var filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");
+ var filePath = html.ViewContext.HttpContext.Server.MapPath(root + entryPoint + ".js");
if (File.Exists(filePath))
{
@@ -132,7 +140,7 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
//search for controller/action.js in common area
entryPoint = string.Format(entryPointTmpl, "Common");
- filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");
+ filePath = html.ViewContext.HttpContext.Server.MapPath(root + entryPoint + ".js");
if (File.Exists(filePath))
{
@@ -142,7 +150,7 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
//search for controller/controller-action.js in current area
entryPointTmpl = "Controllers/{0}/" + routingInfo.Controller + "/" + routingInfo.Controller + "-" + routingInfo.Action;
entryPoint = string.Format(entryPointTmpl, routingInfo.Area);
- filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");
+ filePath = html.ViewContext.HttpContext.Server.MapPath(root + entryPoint + ".js");
if (File.Exists(filePath))
{
@@ -151,7 +159,7 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
//search for controller/controller-action.js in common area
entryPoint = string.Format(entryPointTmpl, "Common");
- filePath = html.ViewContext.HttpContext.Server.MapPath("~/Scripts/" + entryPoint + ".js");
+ filePath = html.ViewContext.HttpContext.Server.MapPath(root + entryPoint + ".js");
if (File.Exists(filePath))
{
@@ -161,8 +169,6 @@ public static MvcHtmlString RequireJsEntryPoint(this HtmlHelper html)
return null;
}
-
-
public static string CurrentCulture(this HtmlHelper html)
{
// split the ro-Ro string by '-' so it returns eg. ro / en