本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例7: ParseTemplate
ParserResults ParseTemplate(ITextBuffer textBuffer)
{
var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
var engine = new RazorTemplateEngine(host);
return engine.ParseTemplate(textBuffer.CreateReader());
}