当前位置: 首页>>代码示例>>C#>>正文


C# RazorTemplateEngine.ParseTemplate方法代码示例

本文整理汇总了C#中System.Web.Razor.RazorTemplateEngine.ParseTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# RazorTemplateEngine.ParseTemplate方法的具体用法?C# RazorTemplateEngine.ParseTemplate怎么用?C# RazorTemplateEngine.ParseTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Razor.RazorTemplateEngine的用法示例。


在下文中一共展示了RazorTemplateEngine.ParseTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadHtmlSpans

		void ReadHtmlSpans(string html)
		{
			RazorEngineHost razorEngineHost = new RazorEngineHost(codeLanguage);
			RazorTemplateEngine engine = new RazorTemplateEngine(razorEngineHost);
			ParserResults results = engine.ParseTemplate(new StringReader(html));
			spans = new List<Span>(results.Document.Flatten());
			spans.RemoveAll(span => span.Kind != SpanKind.Markup);
		}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:8,代码来源:RazorHtmlSpans.cs

示例2: ReadBlockSpans

 void ReadBlockSpans(string markup)
 {
     var razorEngineHost = new RazorEngineHost(codeLanguage);
     var engine = new RazorTemplateEngine(razorEngineHost);
     var results = engine.ParseTemplate(new StringReader(markup));
     spans = new List<Span>(results.Document.Flatten());
     spans.RemoveAll(span => !span.IsBlock);
 }
开发者ID:RazorPad,项目名称:RazorPad,代码行数:8,代码来源:RazorSpans.cs

示例3: Parse

        public IEnumerable<Span> Parse(string viewFile)
        {
            var codeLanguage = RazorCodeLanguageFactory.Create(viewFile.FileExtension());

            using (var fileStream = new FileStream(viewFile, FileMode.Open, FileAccess.Read))
            using (var reader = new StreamReader(fileStream))
            {
                var templateEngine = new RazorTemplateEngine(new RazorEngineHost(codeLanguage));
                var parseResults = templateEngine.ParseTemplate(reader);
                return parseResults.Document.Flatten();
            }
        }
开发者ID:src75,项目名称:ToDoSample,代码行数:12,代码来源:ViewParser.cs

示例4: Parse

        internal void Parse(TextReader razorTemplate, TextWriter output)
        {
            RazorEngineHost host = new RazorEngineHost(new CSharpRazorCodeLanguage());
            RazorTemplateEngine engine = new RazorTemplateEngine(host);

            ParserResults result = engine.ParseTemplate(razorTemplate);

            if (!result.Success)
            {
                ThrowParserError(result);
            }
            WriteTemplateFunction(result.Document, output);
        }
开发者ID:bevacqua,项目名称:Razor.Js,代码行数:13,代码来源:RazorJsEngine.cs

示例5: RenderClientTemplate

        public virtual void RenderClientTemplate(TextReader razorTemplate, TextWriter output)
        {
            var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
            var engine = new RazorTemplateEngine(host);

            var parserResults = engine.ParseTemplate(razorTemplate);

            if(parserResults.Success == false)
                // TODO: Less suck
                throw new RazorClientTemplateException("Template parse exception");

            RenderClientTemplate(parserResults.Document, output);
        }
开发者ID:jchadwick,项目名称:RazorClientTemplates,代码行数:13,代码来源:RazorClientTemplateEngine.cs

示例6: Parse

        public IEnumerable<Span> Parse(string viewFile)
        {
            RazorCodeLanguage language;
            switch (viewFile.FileExtension())
            {
                case ".cshtml":
                    language = new CSharpRazorCodeLanguage(true);
                    break;
                case ".vbhtml":
                    language = new VBRazorCodeLanguage(true);
                    break;
                default:
                    throw new ArgumentException("Invalid extension for Razor engine.");
            }

            using (var fileStream = new FileStream(viewFile, FileMode.Open, FileAccess.Read))
            using (var reader = new StreamReader(fileStream))
            {
                var engine = new RazorTemplateEngine(new RazorEngine.Compilation.RazorEngineHost(language, () => new HtmlMarkupParser()));
                var parseResults = engine.ParseTemplate(reader);
                return parseResults.Document.Flatten();
            }
        }
开发者ID:hartez,项目名称:FubuMVC.ViewEngines,代码行数:23,代码来源:ViewParser.cs

示例7: ParseTemplate

		ParserResults ParseTemplate(ITextBuffer textBuffer)
		{
			var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
			var engine = new RazorTemplateEngine(host);
			return engine.ParseTemplate(textBuffer.CreateReader());
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:6,代码来源:RazorCSharpModelTypeLocater.cs


注:本文中的System.Web.Razor.RazorTemplateEngine.ParseTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。