-
Notifications
You must be signed in to change notification settings - Fork 46
Rendering the configuration entrypoint
Rendering is done using the RenderRequireJsSetup
html helper.
The object it takes (of class RequireRendererConfiguration) as a parameter has the following properties:
-
RequireJsUrl
: url for the require.js script -
BaseUrl
: baseUrl to be passed to require.js. All module paths will be relative to this setting. -
ConfigurationFiles
: a list of configuration files. If none are provided, it will default to a list containingRequireJS.json
. -
EntryPointRoot
: The path used to compose the entryPoint location. Default is~/Scripts/
-
LoadOverrides
: This value established if we load the overrides defined in the configuration file generated by the AutoCompressor -
UrlArgs
: A value to be passed to require.js, mainly used for script versioning. -
LocaleSelector
: A function that allows you to define what the value oflocale
passed to require.js should be. Used in internationalization. -
Logger
: An instance ofIRequireJsLogger
used to log various warnings at runtime -
ProcessConfig
: An action that allows you to modify any of the properties defined in the configuration object. -
ProcessOptions
: An action that allows you to modify any of the properties defined in the options object
Example
@using RequireJsNet
<!DOCTYPE html>
<html>
<head>
<!-- head content -->
</head>
<body>
<!-- body content -->
@Html.RenderRequireJsSetup(new RequireRendererConfiguration
{
// the url from where require.js will be loaded
RequireJsUrl = Url.Content("~/Scripts/Components/RequireJS/require.js"),
// baseUrl to be passed to require.js, will be used when composing urls for scripts
BaseUrl = Url.Content("~/Scripts/"),
// a list of all the configuration files you want to load
ConfigurationFiles = new[] { "~/RequireJS.json" },
// root folder for your js controllers, will be used for composing paths to entrypoint
EntryPointRoot = "~/Scripts/",
// whether we should load overrides or not, used for autoBundles, disabled on debug mode
LoadOverrides = !HttpContext.Current.IsDebuggingEnabled,
// compute the value you want locale to have, used for i18n
LocaleSelector = html => System.Threading.Thread.CurrentThread.CurrentUICulture.Name.Split('-')[0],
// instance of IRequireJsLogger
Logger = null,
// extensability point for the config object
ProcessConfig = config => { },
// extensability point for the options object
ProcessOptions = options => { },
// value for urlArgs to be passed to require.js, used for versioning
UrlArgs = "v1.0"
})
</body>
</html>
[Passing values between ASP.NET and JavaScript] (https://github.com/vtfuture/RequireJSDotNet/wiki/Passing-values-between-ASP.NET-and-JavaScript)