Beispiel #1
0
 private void WriteUnparsedTag(HtmlTag tag)
 {
     switch (tag.TagName)
     {
         case "%@":
         {
             // store directive for specialized parsing
             this.Directives.Append(tag.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(tag.Content);
             break;
         }
         case "%#": // databinding expression
         {
             // unparsed expressions are emitted directly into JBST
             JbstUnparsedBlock code = new JbstUnparsedBlock(tag.Content);
             this.AppendChild(code);
             break;
         }
         case "%=": // inline expression
         {
             // expressions are emitted directly into JBST
             JbstExpressionBlock code = new JbstExpressionBlock(tag.Content);
             this.AppendChild(code);
             break;
         }
         case "%$":
         {
             // expressions are emitted directly into JBST
             JbstExtensionBlock code = new JbstExtensionBlock(tag.Content, this.path);
             this.AppendChild(code);
             break;
         }
         case "%":
         {
             // statements are emitted directly into JBST
             JbstStatementBlock code = new JbstStatementBlock(tag.Content);
             this.AppendChild(code);
             break;
         }
         case "%--":
         {
             // server-side comments are omitted even for debug
             break;
         }
         case "!--":
         {
             // HTML Comments are emitted directly into JBST
             JbstCommentBlock code = new JbstCommentBlock(tag.Content);
             this.AppendChild(code);
             break;
         }
         default:
         {
             // unrecognized sequences get emitted as encoded text
             this.AppendChild(tag.ToString());
             break;
         }
     }
 }
Beispiel #2
0
        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;
                    }
                    }
                }
            }
        }
Beispiel #3
0
        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;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void WriteUnparsedTag(HtmlTag tag)
        {
            switch (tag.TagName)
            {
            case "%@":
            {
                // store directive for specialized parsing
                this.Directives.Append(tag.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(tag.Content);
                break;
            }

            case "%#":                     // databinding expression
            {
                // unparsed expressions are emitted directly into JBST
                JbstUnparsedBlock code = new JbstUnparsedBlock(tag.Content);
                this.AppendChild(code);
                break;
            }

            case "%=":                     // inline expression
            {
                // expressions are emitted directly into JBST
                JbstExpressionBlock code = new JbstExpressionBlock(tag.Content);
                this.AppendChild(code);
                break;
            }

            case "%$":
            {
                // expressions are emitted directly into JBST
                JbstExtensionBlock code = new JbstExtensionBlock(tag.Content, this.path);
                this.AppendChild(code);
                break;
            }

            case "%":
            {
                // statements are emitted directly into JBST
                JbstStatementBlock code = new JbstStatementBlock(tag.Content);
                this.AppendChild(code);
                break;
            }

            case "%--":
            {
                // server-side comments are omitted even for debug
                break;
            }

            case "!--":
            {
                // HTML Comments are emitted directly into JBST
                JbstCommentBlock code = new JbstCommentBlock(tag.Content);
                this.AppendChild(code);
                break;
            }

            default:
            {
                // unrecognized sequences get emitted as encoded text
                this.AppendChild(tag.ToString());
                break;
            }
            }
        }