コード例 #1
0
ファイル: MarkupRule.cs プロジェクト: richiejp/NHaml
        protected static void AppendText(string text, TemplateClassBuilder builder, TemplateOptions options)
        {
            var encodeHtml = options.EncodeHtml;
            if (text.StartsWith("!"))
            {
                text = text.Substring(1, text.Length - 1);
                text.TrimStart(' ');
                encodeHtml = false;
            }
            if (text.StartsWith("&"))
            {
                text = text.Substring(1, text.Length - 1);
                text.TrimStart(' ');
                encodeHtml = true;
            }

            var parser = new ExpressionStringParser(text);
            parser.Parse();
            foreach (var expressionStringToken in parser.ExpressionStringTokens)
            {
                if (expressionStringToken.IsExpression)
                {
                    builder.AppendCode(expressionStringToken.Value, encodeHtml);
                }
                else
                {
                    builder.AppendOutput(expressionStringToken.Value);
                }
            }
        }
コード例 #2
0
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var partialName = viewSourceReader.CurrentInputLine.NormalizedText.Trim();

            if (string.IsNullOrEmpty(partialName))
            {
                if (viewSourceReader.ViewSourceQueue.Count == 0)
                {
                    throw new InvalidOperationException(NoPartialName);
                }
                var templatePath = viewSourceReader.ViewSourceQueue.Dequeue();
                viewSourceReader.MergeTemplate(templatePath, true);
            }
            else
            {
                partialName = partialName.Insert(partialName.LastIndexOf(@"\", StringComparison.OrdinalIgnoreCase) + 1, "_");
                IViewSource viewSource;
                try
                {
                    viewSource = options.TemplateContentProvider.GetViewSource(partialName, viewSourceReader.ViewSources);
                }
                catch (FileNotFoundException)
                {
                    //ToDo: render content behind the ? tag
                    viewSource = null;
                }
                viewSourceReader.ViewSourceModifiedChecks.Add(() => viewSource.IsModified);
                viewSourceReader.MergeTemplate(viewSource, true);
            }

            return EmptyClosingAction;
        }
コード例 #3
0
        public BlockClosingAction RenderSilentEval(ViewSourceReader viewSourceReader, TemplateClassBuilder builder)
        {
            var code = viewSourceReader.CurrentInputLine.NormalizedText;

            var lambdaMatch = lambdaRegex.Match( code );

            if( !lambdaMatch.Success )
            {
                builder.AppendSilentCode(code, !viewSourceReader.IsBlock);

                if( viewSourceReader.IsBlock )
                {
                    builder.BeginCodeBlock();

                    return builder.EndCodeBlock;
                }

                return MarkupRule.EmptyClosingAction;
            }

            var depth = viewSourceReader.CurrentInputLine.IndentCount;
            code = TranslateLambda( code, lambdaMatch );

            builder.AppendChangeOutputDepth(depth);
            builder.AppendSilentCode(code, true);

            return () =>
                       {
                           builder.AppendChangeOutputDepth(depth);
                           builder.AppendSilentCode("})", true);
                       };
        }
コード例 #4
0
ファイル: DocTypeMarkupRule.cs プロジェクト: Jeff-Lewis/nhaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var currentInputLine = viewSourceReader.CurrentInputLine;
            var content = currentInputLine.NormalizedText.Trim().ToLowerInvariant();

            if (string.IsNullOrEmpty(content))
            {
                builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">");
            }
            else if (string.Equals(content, "1.1"))
            {
                builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.1//EN"" ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">");
            }
            else if (string.Equals(content, "strict"))
            {
                builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">");
            }
            else if (string.Equals(content, "frameset"))
            {
                builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Frameset//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"">");
            }
            else if (string.Equals(content, "html"))
            {
                builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">");
            }
            else if (string.Equals(content, "html strict"))
            {
                builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">");
            }
            else if (string.Equals(content, "html frameset"))
            {
                builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Frameset//EN"" ""http://www.w3.org/TR/html4/frameset.dtd"">");
            }
            else
            {
                var parts = content.Split(' ');

                if (string.Equals(parts[0], "xml"))
                {
                    var encoding = "utf-8";

                    if (parts.Length == 2)
                    {
                        encoding = parts[1];
                    }

                    var invariant = Utility.FormatInvariant(@"<?xml version=""1.0"" encoding=""{0}"" ?>", encoding);
                    builder.AppendOutput(invariant);
                }
                else
                {
                    SyntaxException.Throw(currentInputLine, ErrorParsingTag,currentInputLine);
                }
            }

            builder.AppendOutputLine();

            return EmptyClosingAction;
        }
コード例 #5
0
ファイル: EscapeMarkupRule.cs プロジェクト: peterjoh/NHaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            builder.AppendOutput(viewSourceReader.CurrentInputLine.Indent);
            builder.AppendOutput(viewSourceReader.CurrentInputLine.NormalizedText);
            builder.AppendOutputLine();

            return EmptyClosingAction;
        }
コード例 #6
0
ファイル: TemplateParser.cs プロジェクト: peterjoh/NHaml
        public TemplateParser(TemplateOptions options, TemplateClassBuilder templateClassBuilder, IList<IViewSource> viewSources)
        {
            BlockClosingActions = new Stack<BlockClosingAction>();

            viewSourceReader = new ViewSourceReader(options, viewSources);
            Options = options;
            builder = templateClassBuilder;
        }
コード例 #7
0
        public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder)
        {
            //var inputLine = viewSourceReader.CurrentInputLine;
            //builder.AppendOutput( inputLine.Indent );

            //builder.AppendCode( inputLine.NormalizedText.Trim(), false );
            //builder.AppendOutputLine();
            return EmptyClosingAction;
        }
コード例 #8
0
ファイル: CommentMarkupRule.cs プロジェクト: Jeff-Lewis/nhaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var currentInputLine = viewSourceReader.CurrentInputLine;
            var match = _commentRegex.Match( currentInputLine.NormalizedText );

            if( !match.Success )
            {
                SyntaxException.Throw( currentInputLine, ErrorParsingTag, currentInputLine);
            }

            var ieBlock = match.Groups[1].Value;
            var content = match.Groups[2].Value;

            var openingTag = new StringBuilder(currentInputLine.Indent);
            openingTag.Append("<!--");
            var closingTag = new StringBuilder("-->");

            if( !string.IsNullOrEmpty( ieBlock ) )
            {
                openingTag.AppendFormat("{0}>",ieBlock);
                closingTag.Insert(0,"<![endif]");
            }

            if( string.IsNullOrEmpty( content ) )
            {
                builder.AppendOutput(openingTag.ToString());
                builder.AppendOutputLine();
                closingTag.Insert(0, currentInputLine.Indent);
            }
            else
            {
                if( content.Length > 50 )
                {
                    builder.AppendOutput(openingTag.ToString());
                    builder.AppendOutputLine();

                    builder.AppendOutput( viewSourceReader.NextIndent );

                    builder.AppendOutput(content);

                    builder.AppendOutputLine();
                }
                else
                {
                    builder.AppendOutput( openingTag.ToString() );
                    builder.AppendOutput( content );
                    closingTag.Insert(0, ' ');
                }
            }

            return () =>
                   {
                       builder.AppendOutput(closingTag.ToString());
                       builder.AppendOutputLine();
                   };
        }
コード例 #9
0
ファイル: EvalMarkupRule.cs プロジェクト: Jeff-Lewis/nhaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var inputLine = viewSourceReader.CurrentInputLine;

            builder.AppendOutput( inputLine.Indent );
            builder.AppendCode(inputLine.NormalizedText.Trim(), options.EncodeHtml);

            builder.AppendOutputLine();
            return EmptyClosingAction;
        }
コード例 #10
0
 public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder)
 {
     //int currentLineIndentCount = viewSourceReader.CurrentInputLine.IndentCount;
     //while ((viewSourceReader.NextInputLine != null)
     //    && (viewSourceReader.NextInputLine.IndentCount > currentLineIndentCount))
     //{
     //    viewSourceReader.MoveNext();
     //}
     return null;
 }
コード例 #11
0
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var code = viewSourceReader.CurrentInputLine.NormalizedText.Trim();

            if( !string.IsNullOrEmpty( code ) )
            {
                builder.AppendPreambleCode( code );
            }

            return EmptyClosingAction;
        }
コード例 #12
0
ファイル: MetaMarkupRule.cs プロジェクト: peterjoh/NHaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var content = viewSourceReader.CurrentInputLine.NormalizedText.Trim().Replace( "\"", "\"\"" );

            var indexOfEquals = content.IndexOf('=');
            var key = content.Substring(0, indexOfEquals).Trim();
            var value = content.Substring(indexOfEquals+1, content.Length - indexOfEquals - 1).Trim();

            builder.Meta[key] = value;

            return EmptyClosingAction;
        }
コード例 #13
0
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var text = viewSourceReader.CurrentInputLine.NormalizedText.TrimStart();
		    var indexOfSpace = text.IndexOf(' ');
            var sectionName = text.Substring(indexOfSpace + 1, text.Length - indexOfSpace - 1);
            var code = string.Format("{0}).AddSection(\"{1}\", x =>", viewSourceReader.CurrentInputLine.Indent, sectionName);

            builder.EndCodeBlock();
            builder.Indent();

            builder.AppendSilentCode(code, false);
            builder.BeginCodeBlock();


            return builder.Unindent;
        }
コード例 #14
0
        private static void BeforeCompile(TemplateClassBuilder templateClassBuilder, object context)
        {
            var templateBuilderContext = (TemplateBuilderContext) context;
            var codeDomClassBuilder = (CodeDomClassBuilder)templateClassBuilder;

            foreach (var pair in templateBuilderContext.Helpers)
            {
                var property = new CodeMemberField
                               {
                                   Name = pair.Key,
                                   Type = new CodeTypeReference(pair.Value),
                                   Attributes = MemberAttributes.Public,
                               };
                codeDomClassBuilder.Members.Add(property);
            }
        }
コード例 #15
0
        public TemplateFactory Compile(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var typeBuilder = CreateTemplateTypeBuilder(options);
            //TODO: leaky abstraction
            var classBuilder = (CodeDomClassBuilder) builder;
            var provider = GetCodeDomProvider(typeBuilder.ProviderOptions);
            classBuilder.CodeDomProvider = provider;
            typeBuilder.CodeDomProvider = provider;
            var templateSource = classBuilder.Build(options.Usings);

            var templateType = typeBuilder.Build( templateSource, classBuilder.ClassName );

            if( templateType == null )
            {
                var viewSources = viewSourceReader.ViewSources;
                TemplateCompilationException.Throw(typeBuilder.CompilerResults, typeBuilder.Source, ListExtensions.Last(viewSources).Path);
            }

            return new TemplateFactory( templateType );
        }
コード例 #16
0
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {

            var dictionary = string.Empty;

            var text = viewSourceReader.CurrentInputLine.NormalizedText.Trim();
            var indexOfSpace = text.IndexOf(' ');
            string componentName ;
            if (indexOfSpace == -1)
            {
                componentName = text.Trim();
            }
            else
            {
                dictionary = text.Substring(indexOfSpace, text.Length - indexOfSpace);
                dictionary = dictionary.Trim();
                Debug.Assert(dictionary.StartsWith("{"), "dictionary must start with '{'");
                Debug.Assert(dictionary.EndsWith("}"), "dictionary must start with '}'");
                dictionary = dictionary.Substring(1, dictionary.Length - 2);
                componentName = text.Substring(0, indexOfSpace);
            }


            var codeDomClassBuilder = (CodeDomClassBuilder)builder;

            var dictionaryLocalVariable = AppendCreateDictionaryLocalVariable(dictionary, codeDomClassBuilder);

        	codeDomClassBuilder.CurrentTextWriterVariableName = "x";
            var code = string.Format("{0}Component(\"{1}\", {2}, (x) =>",
                                     viewSourceReader.CurrentInputLine.Indent, componentName, dictionaryLocalVariable);

            codeDomClassBuilder.AppendSilentCode(code, false);
            codeDomClassBuilder.BeginCodeBlock();
			return () =>
			       	{
			       		codeDomClassBuilder.EndCodeBlock();
			       		codeDomClassBuilder.AppendSilentCode(").Render();", false);
			       		codeDomClassBuilder.CurrentTextWriterVariableName = TemplateClassBuilder.DefaultTextWriterVariableName;
			       	};
        }
コード例 #17
0
ファイル: PartialMarkupRule.cs プロジェクト: richiejp/NHaml
        public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder)
        {
            //var partialName = viewSourceReader.CurrentInputLine.NormalizedText.Trim();

            //if (string.IsNullOrEmpty(partialName))
            //{
            //    if (viewSourceReader.ViewSourceQueue.Count == 0)
            //    {
            //        throw new InvalidOperationException(NoPartialName);
            //    }
            //    var templatePath = viewSourceReader.ViewSourceQueue.Dequeue();
            //    viewSourceReader.MergeTemplate(templatePath, true);
            //}
            //else
            //{
            //    partialName = partialName.Insert(partialName.LastIndexOf(@"\", StringComparison.OrdinalIgnoreCase) + 1, "_");
            //    var viewSource = options.TemplateContentProvider.GetViewSource(partialName, viewSourceReader.ViewSources);
            //    viewSourceReader.ViewSourceModifiedChecks.Add(() => viewSource.IsModified);
            //    viewSourceReader.MergeTemplate(viewSource, true);
            //}

            return EmptyClosingAction;
        }
コード例 #18
0
 public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
 {
     return options.TemplateCompiler.RenderSilentEval(viewSourceReader, builder);
 }
コード例 #19
0
ファイル: TagMarkupRule.cs プロジェクト: peterjoh/NHaml
        private static void ParseAndRenderAttributes(TemplateClassBuilder builder, Match tagMatch)
        {
            var idAndClasses = tagMatch.Groups[2].Value;
            var attributesHash = tagMatch.Groups[4].Value.Trim();

            var match = _idClassesRegex.Match(idAndClasses);

            var classes = new List<string>();

            foreach (Capture capture in match.Groups[2].Captures)
            {
                classes.Add(capture.Value);
            }

            if (classes.Count > 0)
            {
                attributesHash = PrependAttribute(attributesHash, Class, string.Join(" ", classes.ToArray()));
            }

            string id = null;
            foreach (Capture capture in match.Groups[1].Captures)
            {
                id = capture.Value;
                break;
            }

            if (!string.IsNullOrEmpty(id))
            {
                attributesHash = PrependAttribute(attributesHash, Id, id);
            }

            if (string.IsNullOrEmpty(attributesHash))
            {
                return;
            }

            var attributeParser = new AttributeParser(attributesHash);
            attributeParser.Parse();
            foreach (var attribute in attributeParser.Attributes)
            {
                if (attribute.Type == ParsedAttributeType.String)
                {
                    var expressionStringParser = new ExpressionStringParser(attribute.Value);

                    expressionStringParser.Parse();

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, expressionStringParser.ExpressionStringTokens);
                }
                else
                {
                    var token = new ExpressionStringToken(attribute.Value, true);

                    builder.AppendAttributeTokens(attribute.Schema, attribute.Name, new[] { token });
                }
            }
        }
コード例 #20
0
ファイル: TagMarkupRule.cs プロジェクト: peterjoh/NHaml
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var currentInputLine = viewSourceReader.CurrentInputLine;
            var input = PreprocessLine(currentInputLine);
            var match = _tagRegex.Match(input);

            if (!match.Success)
            {
                SyntaxException.Throw(currentInputLine, ErrorParsingTag, currentInputLine);
            }

            var groups = match.Groups;
            var tagName = groups[1].Value.Replace("\\", string.Empty);

            var isWhitespaceSensitive = _whitespaceSensitiveTags.Contains(tagName);
            var openingTag = string.Format("{0}<{1}", currentInputLine.Indent, tagName);
            var closingTag = string.Format("</{0}>", tagName);

            builder.AppendOutput(openingTag);

            ParseAndRenderAttributes(builder, match);

            var action = groups[6].Value.Trim();

            if (string.Equals("/", action) || options.IsAutoClosingTag(tagName))
            {
                builder.AppendOutput(" />");
                builder.AppendOutputLine();
                return EmptyClosingAction;
            }

            var content = groups[7].Value.Trim();

            if (string.IsNullOrEmpty(content))
            {
                builder.AppendOutput(">");
                builder.AppendOutputLine();
                closingTag = currentInputLine.Indent + closingTag;
            }
            else
            {
                if ((content.Length > 50) || ("=" == action) || ("&=" == action) || ("!=" == action))
                {
                    builder.AppendOutput(">");

                    if (!isWhitespaceSensitive)
                    {
                        builder.AppendOutputLine();
                        builder.AppendOutput(viewSourceReader.NextIndent);
                    }

                    if (string.Equals("=", action))
                    {
                        builder.AppendCode(content, options.EncodeHtml);
                    }
                    else if (string.Equals("&=", action))
                    {
                        builder.AppendCode(content, true);
                    }
                    else if (string.Equals("!=", action))
                    {
                        builder.AppendCode(content, false);
                    }
                    else
                    {
                        AppendText(content, builder, options);
                    }

                    if (!isWhitespaceSensitive)
                    {
                        builder.AppendOutputLine();
                        closingTag = currentInputLine.Indent + closingTag;
                    }
                }
                else
                {
                    builder.AppendOutput(">");
                    AppendText(content, builder, options);
                    if ((currentInputLine.IndentCount + 1) == viewSourceReader.NextInputLine.IndentCount)
                    {
                        builder.AppendOutputLine();
                        closingTag = currentInputLine.Indent + closingTag;
                    }
                }
            }

            return () =>
            {
                builder.AppendOutput(closingTag);
                builder.AppendOutputLine();
            };
        }
コード例 #21
0
 public override BlockClosingAction Render(HamlNode hamlNode, TemplateOptions options, TemplateClassBuilder builder)
 {
     //return options.TemplateCompiler.RenderSilentEval(viewSourceReader, builder);
     return null;
 }
コード例 #22
0
ファイル: MarkupRule.cs プロジェクト: richiejp/NHaml
 public abstract BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder);
コード例 #23
0
        public BlockClosingAction RenderSilentEval(ViewSourceReader viewSourceReader, TemplateClassBuilder builder)
        {
            var code = viewSourceReader.CurrentInputLine.NormalizedText;

            var lambdaMatch = lambdaRegex.Match(code);

            if (!lambdaMatch.Success)
            {
                builder.AppendSilentCode(code, !viewSourceReader.IsBlock);

                if (viewSourceReader.IsBlock)
                {
                    builder.BeginCodeBlock();

                    return(builder.EndCodeBlock);
                }

                return(MarkupRule.EmptyClosingAction);
            }

            var depth = viewSourceReader.CurrentInputLine.IndentCount;

            code = TranslateLambda(code, lambdaMatch);

            builder.AppendChangeOutputDepth(depth);
            builder.AppendSilentCode(code, true);

            return(() =>
            {
                builder.AppendChangeOutputDepth(depth);
                builder.AppendSilentCode("})", true);
            });
        }
コード例 #24
0
        public TemplateFactory Compile(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var typeBuilder = CreateTemplateTypeBuilder(options);
            //TODO: leaky abstraction
            var classBuilder = (CodeDomClassBuilder)builder;
            var provider     = GetCodeDomProvider(typeBuilder.ProviderOptions);

            classBuilder.CodeDomProvider = provider;
            typeBuilder.CodeDomProvider  = provider;
            var templateSource = classBuilder.Build(options.Usings);

            var templateType = typeBuilder.Build(templateSource, classBuilder.ClassName);

            if (templateType == null)
            {
                var viewSources = viewSourceReader.ViewSources;
                TemplateCompilationException.Throw(typeBuilder.CompilerResults, typeBuilder.Source, ListExtensions.Last(viewSources).Path);
            }

            return(new TemplateFactory(templateType));
        }
コード例 #25
0
ファイル: DocTypeMarkupRule.cs プロジェクト: richiejp/NHaml
        public override BlockClosingAction Render(HamlNode node, TemplateOptions options, TemplateClassBuilder builder)
        {
            //var currentInputLine = viewSourceReader.CurrentInputLine;
            //var content = currentInputLine.NormalizedText.Trim().ToLowerInvariant();

            //if (string.IsNullOrEmpty(content))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">");
            //}
            //else if (string.Equals(content, "1.1"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.1//EN"" ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">");
            //}
            //else if (string.Equals(content, "strict"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">");
            //}
            //else if (string.Equals(content, "frameset"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Frameset//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"">");
            //}
            //else if (string.Equals(content, "html"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">");
            //}
            //else if (string.Equals(content, "html strict"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01//EN"" ""http://www.w3.org/TR/html4/strict.dtd"">");
            //}
            //else if (string.Equals(content, "html frameset"))
            //{
            //    builder.AppendOutput(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Frameset//EN"" ""http://www.w3.org/TR/html4/frameset.dtd"">");
            //}
            //else if (string.Equals(content, "mobile"))
            //{
            //    builder.AppendOutput("<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">");
            //}
            //else if (string.Equals(content, "basic"))
            //{
            //    builder.AppendOutput("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML Basic 1.1//EN\" \"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd\">");
            //}
            //else
            //{
            //    var parts = content.Split(' ');

            //    if (string.Equals(parts[0], "xml"))
            //    {
            //        var encoding = "utf-8";

            //        if (parts.Length == 2)
            //        {
            //            encoding = parts[1];
            //        }

            //        var invariant = Utility.FormatInvariant(@"<?xml version=""1.0"" encoding=""{0}"" ?>", encoding);
            //        builder.AppendOutput(invariant);
            //    }
            //    else
            //    {
            //        SyntaxException.Throw(currentInputLine, ErrorParsingTag,currentInputLine);
            //    }
            //}

            //builder.AppendOutputLine();

            return EmptyClosingAction;
        }
コード例 #26
0
ファイル: EofMarkupRule.cs プロジェクト: peterjoh/NHaml
 public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
 {
     return EmptyClosingAction;
 }
コード例 #27
0
ファイル: MarkupRule.cs プロジェクト: Jeff-Lewis/nhaml
 public abstract BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder);