public void MoveScriptLocation() { CQ doc = CQ.Create(@" <html> <head> <script type='text/javascript' src='~/script' class='inhead'></script> </head> <body> <div></div> <script type='text/javascript' src='~/script' class='inbody' data-location='head'></script> </body> "); var mgr = new ScriptManager(MapPath, ResolveUrl); mgr.Options = ViewEngineOptions.ProcessAllScripts | ViewEngineOptions.IgnoreMissingScripts; Assert.AreEqual(1,doc["head"].Children().Length); mgr.ResolveScriptDependencies(doc); Assert.AreEqual(3, doc["head"].Children().Length); Assert.AreEqual(doc[".inbody"][0].ParentNode, doc["head"][0]); var libScript =doc["head > .csquery-generated"]; Assert.AreEqual(1, libScript.Length, "The library include was added."); Assert.AreEqual(libScript[0].ParentNode.ChildElements.First(), libScript[0],"The library include was first element."); }
private void ManageScripts(CQ cqDoc, WebViewPage viewPage) { ScriptManager mgr = new ScriptManager(); mgr.Options = Options; mgr.LibraryPath = LibraryPath; mgr.ResolveScriptDependencies(cqDoc); }
/// <summary> /// Manage scripts. /// </summary> /// /// <param name="cqDoc"> /// The cq document. /// </param> /// <param name="viewPage"> /// The view page. /// </param> /// <param name="viewContext"> /// The active view context /// </param> private void ManageScripts(CQ cqDoc, WebViewPage viewPage, ViewContext viewContext) { ScriptManager mgr = new ScriptManager(new ScriptEnvironment { LibraryPath = LibraryPath, RelativePathRoot =viewContext.RequestContext.HttpContext.Request.AppRelativeCurrentExecutionFilePath, MapPath = viewContext.RequestContext.HttpContext.Server.MapPath }); mgr.Options = Options; mgr.ResolveScriptDependencies(cqDoc); }