Example #1
0
        /// <summary>
        /// Load a script file and return it as an html string
        /// </summary>
        /// <param name="script">The name of the script to load</param>
        /// <returns>An MvcHtmlString of containing the requested script</returns>
        public static MvcHtmlString LoadScript(string script)
        {
            if (string.IsNullOrWhiteSpace(script))
            {
                return(new MvcHtmlString(string.Empty));
            }
            var package = new Core.CdnJs().GetPackage(script);

            if (package != null)
            {
                return(new MvcHtmlString(@"<script src=""" + string.Format(BaseScriptUrl, package.Name, package.Version, package.Filename) + @"""></script>"));
            }

            return(new MvcHtmlString(string.Empty));
        }
        /// <summary>
        /// Load a script file and return it as an html string
        /// </summary>
        /// <param name="script">The name of the script to load</param>
        /// <returns>An MvcHtmlString of containing the requested script</returns>
        public static MvcHtmlString LoadScript(string script)
        {
            if(string.IsNullOrWhiteSpace(script))
            {
                return new MvcHtmlString(string.Empty);
            }
            var package = new Core.CdnJs().GetPackage(script);

            if(package != null)
            {
                return new MvcHtmlString(@"<script src=""" + string.Format(BaseScriptUrl, package.Name, package.Version, package.Filename)  + @"""></script>");
            }

            return new MvcHtmlString(string.Empty);
        }