Clone wiki

MinCat / Extensions

MVC and Web Forms Extensions

MinCat provides some basic extensions for both MVC and Web Forms projects. Although use of these extensions is entirely optional, they are recommended.

Html.Script(source, [contextName], [minimize])

Produces the script tags necessary to load the script specified by the source parameter. If the source declares any dependencies using one or more @require directives, those dependencies will also be loaded in their own script tags.

If the optional contextName parameter is specified, then the named context will be used. Otherwise, your default context will apply.

If the optional minimize parameter is true, the resulting script tag will load the minimzied version of the JavaScript. If this parameter is false, the script tag will always load the un-minimized version. When this parameter is omitted, MinCat will honor the system.web/configuration/@debug value in your site's web.config.

Html.RequireScript(source)

This causes MinCat to remember that a script is needed on the page. Now, even deeply nested partial views or commonly used EditorTemplates can register a required script. MinCat will track these requirements for you, automatically weeding out duplicate script tags and maintaining the correct order.

Html.RenderScripts([contextName], [minimize])

Produces all of the script tags that were previously registered by RequireScript.

If the optional contextName parameter is specified, then the named context will be used. Otherwise, your default context will apply.

If the optional minimize parameter is true, the resulting script tag will load the minimzied version of the JavaScript. If this parameter is false, the script tag will always load the un-minimized version. When this parameter is omitted, MinCat will honor the system.web/configuration/@debug value in your site's web.config.

Html.RequireStyle(source) and Html.RenderStyles()

These two methods provide the same Require and Render functionality for CSS files as the RequireScript and RenderScripts methods provide for JavaScript files.

These methods are provided as a convenience only. Unlike JavaScript files, MinCat does not attempt to manage dependencies for CSS files. If you need to include advanced style management on your site, check out MinCat's sister project, SassBuild!

Updated