JsonFx.UI.Jbst.JbstWriter.WriteAttributes C# (CSharp) Method

WriteAttributes() private method

private WriteAttributes ( HtmlTag tag ) : void
tag JsonFx.BuildTools.HtmlDistiller.HtmlTag
return void
        private void WriteAttributes(HtmlTag tag)
        {
            foreach (KeyValuePair<string, object> attrib in tag.FilteredAttributes)
            {
                // normalize JBST command names
                string key = attrib.Key.StartsWith(JbstCommandBase.JbstPrefix, StringComparison.OrdinalIgnoreCase) ?
                    attrib.Key.ToLowerInvariant() : attrib.Key;

                if (attrib.Value is string)
                {
                    this.AddAttribute(attrib.Key, (string)attrib.Value);
                }
                else if (attrib.Value is HtmlTag)
                {
                    HtmlTag codeVal = (HtmlTag)attrib.Value;
                    switch (codeVal.TagName)
                    {
                        case "%@":
                        {
                            // store directive for specialized parsing
                            this.Directives.Append(codeVal.ToString());
                            break;
                        }
                        case "%!":
                        {
                            // analogous to static code, or JSP declarations
                            // executed only on initialization of template
                            // output from declarations are appended after the template
                            this.Declarations.Append(codeVal.Content);
                            break;
                        }
                        case "%#": // databinding expression
                        //{
                        //    // unparsed expressions are emitted directly into JBST
                        //    JbstUnparsedBlock code = new JbstUnparsedBlock(codeVal.Content);
                        //    this.AddAttribute(key, code);
                        //    break;
                        //}
                        case "%=": // inline expression
                        {
                            // expressions are emitted directly into JBST
                            JbstExpressionBlock code = new JbstExpressionBlock(codeVal.Content);
                            this.AddAttribute(key, code);
                            break;
                        }
                        case "%$":
                        {
                            // expressions are emitted directly into JBST
                            JbstExtensionBlock code = new JbstExtensionBlock(codeVal.Content, this.path);
                            this.AddAttribute(key, code);
                            break;
                        }
                        case "%":
                        {
                            // statements are emitted directly into JBST
                            JbstStatementBlock code = new JbstStatementBlock(codeVal.Content);
                            this.AddAttribute(key, code);
                            break;
                        }
                        case "%--":
                        {
                            // server-side comments are omitted even for debug
                            break;
                        }
                        case "!--":
                        {
                            // HTML Comments are emitted directly into JBST
                            // but get removed when minified
                            JbstCommentBlock code = new JbstCommentBlock(codeVal.Content);
                            this.AddAttribute(key, code);
                            break;
                        }
                        default:
                        {
                            // unrecognized sequences get emitted as encoded text
                            this.AddAttribute(key, codeVal.ToString());
                            break;
                        }
                    }
                }
            }
        }