Subtext.Framework.UI.Skinning.ScriptElementCollectionRenderer.RenderScriptElementCollection C# (CSharp) Method

RenderScriptElementCollection() public method

Renders the script element collection for thes kin key.
public RenderScriptElementCollection ( string skinKey ) : string
skinKey string The skin key.
return string
        public string RenderScriptElementCollection(string skinKey)
        {
            StringBuilder result = new StringBuilder();

            SkinTemplate skinTemplate = templates.GetTemplate(skinKey);
            if (skinTemplate != null && skinTemplate.Scripts != null)
            {
                string skinPath = GetSkinPath(skinTemplate.TemplateFolder);
                if(CanScriptsBeMerged(skinTemplate))
                {
                    result.Append(RenderScriptElement(skinPath + "js.axd?name=" + skinKey));
                }
                else
                {
                    foreach (Script script in skinTemplate.Scripts)
                    {
                        result.Append(RenderScriptElement(skinPath, script));
                    }
                }
            }
            return result.ToString();
        }

Usage Example

コード例 #1
0
        public void ScriptElementCollectionRendererRendersScriptElements()
        {
            UnitTestHelper.SetHttpContextWithBlogRequest("localhost", "blog", string.Empty);

            var pathProvider = new Mock<VirtualPathProvider>();
            pathProvider.SetupSkins();
            var skinEngine = new SkinEngine(pathProvider.Object);
            var renderer = new ScriptElementCollectionRenderer(skinEngine);
            string scriptElements = renderer.RenderScriptElementCollection("RedBook-Green.css");

            string script = @"<script type=""text/javascript"" src=""/Skins/RedBook/blah.js""></script>";
            Assert.IsTrue(scriptElements.Contains(script), "Rendered the script improperly.");

            scriptElements = renderer.RenderScriptElementCollection("Nature-Leafy.css");
            script = @"<script type=""text/javascript"" src=""/scripts/XFNHighlighter.js""></script>";
            Assert.IsTrue(scriptElements.Contains(script), "Rendered the script improperly. We got: " + scriptElements);
        }
All Usage Examples Of Subtext.Framework.UI.Skinning.ScriptElementCollectionRenderer::RenderScriptElementCollection