private static string ParseDependency(string line) { string path = null; if (line == null) { return(null); } if (line.StartsWith("/// <depends")) { // old way: /// <depends path="$skin/scripts/jquery/jquery.js" /> var startidx = line.IndexOf('"'); var endidx = line.LastIndexOf('"'); path = line.Substring(startidx + 1, endidx - startidx - 1); } else if (line.StartsWith("//")) { // new way: var linePart = line.Substring(2).Trim(); if (linePart.StartsWith(_usingStr)) { // // using $skin/scripts/jquery/jquery.js path = linePart.Substring(_usingStr.Length).Trim(); } else if (linePart.StartsWith(_resourceStr)) { // // resource UserBrowse var className = linePart.Substring(_resourceStr.Length).Trim(); path = ResourceScripter.GetResourceUrl(className); } else { string tempCategory; // template script will be resolved later on-the-fly, when the context is available if (HtmlTemplate.TryParseTemplateCategory(linePart, out tempCategory)) { path = linePart; } } } return(path); }
private void AddDependencies(string relPath) { var deps = GetDependencies(relPath); var dependencies = deps == null ? new string[0] : deps.ToArray(); // Pre-process dependencies before adding them to the cache (!) and the header. for (var i = 0; i < dependencies.Length; i++) { string templateCategory; // in case of template dependencies we have to resolve them here on-the-fly, when the context is known if (HtmlTemplate.TryParseTemplateCategory(dependencies[i], out templateCategory)) { dependencies[i] = UITools.GetTemplateScriptRequest(templateCategory); } } CacheDeps(relPath, dependencies); foreach (var d in dependencies) { AddScript(d); } }
/// <summary> /// Gets a script request url for templates in the provided category. The current /// context and skin will be used to generate the script url. /// </summary> public static string GetTemplateScriptRequest(string category) { var content = Content.Create(PortalContext.Current.ContextNode); return(HtmlTemplate.GetTemplateScriptRequest(content, SkinManager.GetCurrentSkinName(), category)); }