/// <summary> /// Run the application. /// </summary> public override BoolMessageItem Execute() { bool useRealHttpContext = false; // Add 2 groups ("locations") to the scripts. Scripts.AddLocation("header", useRealHttpContext); Scripts.AddLocation("footer", useRealHttpContext); // 1. Register a css style sheet. Scripts.AddCss("default_theme", "/themes/default/theme.css"); // 2. Register a javascript file Scripts.AddJavascript("comlib.js", "/scripts/core/comlib.js"); // 3. Register a javascript file in a specific location group "header" Scripts.AddJavascript("comlib.js", "/scripts/core/comlib.js", "header"); // 4. Get access to a location. ScriptsHolder header = Scripts.For("header"); // 5. Generate html for the default group "footer". Scripts.ToHtml(); // 6. Generate html for the registered styles/scripts in a specific group. var html = Scripts.ToHtml("header"); return(BoolMessageItem.True); }
public void CanRegister() { Scripts.AddLocation("head", false); Scripts.AddLocation("footer", false); Scripts.AddJavascript("jquery.latest", "/scripts/jquery.1.4.2.js"); Scripts.AddCss("app.css", "/styles/app.css"); var head = Scripts.ToHtml(); var expected = "<script src=\"/scripts/jquery.1.4.2.js\" type=\"text/javascript\"></script>" + Environment.NewLine + "<link href=\"/styles/app.css\" rel=\"stylesheet\" type=\"text/css\" />" + Environment.NewLine; Assert.AreEqual(head, expected); }
public void CanAddToHead() { Scripts.AddLocation("head", false); Scripts.AddLocation("foot", false); Scripts.AddJavascript("jquery.latest", "/scripts/jquery.1.4.2.js", "head"); Scripts.AddCss("app.css", "/styles/app.css", "head"); // Add to foot section. Scripts.AddJavascript("comlib.js", "/scripts/comlib.js", "foot"); // Only get the html for the head section. var head = Scripts.ToHtml("head"); var expected = "<script src=\"/scripts/jquery.1.4.2.js\" type=\"text/javascript\"></script>" + Environment.NewLine + "<link href=\"/styles/app.css\" rel=\"stylesheet\" type=\"text/css\" />" + Environment.NewLine; Assert.AreEqual(head, expected); }