public ParserPipeline BuildHelperPipeline(Helpers helpers) { var builder = new ParserPipelineBuilder(); builder.AddBefore <InterpolationTagParser>(new HelperTagParser(helpers.HelperMap)); return(builder.Build()); }
public void It_Should_Be_Able_To_Replace_BlockParsers() { var builder = new ParserPipelineBuilder(); builder.Replace <SectionTagParser>(new MyCustomBlockParser()); var pipeline = builder.Build(); Assert.DoesNotContain(pipeline.BlockParsers, p => p is SectionTagParser); }
public void It_Should_Be_Able_To_Replace_InlineParsers() { var builder = new ParserPipelineBuilder(); builder.Replace <InterpolationTagParser>(new MyCustomInlineParser()); var pipeline = builder.Build(); Assert.DoesNotContain(pipeline.InlineParsers, p => p is InterpolationTagParser); }
public void It_Should_Be_Able_To_AddBefore_InlineParsers() { var builder = new ParserPipelineBuilder(); builder.AddBefore <InterpolationTagParser>(new MyCustomInlineParser()); var pipeline = builder.Build(); Assert.Contains(pipeline.InlineParsers, p => p is InterpolationTagParser); Assert.Contains(pipeline.InlineParsers, p => p is MyCustomInlineParser); var interpolationIndex = pipeline.InlineParsers.FindIndex(p => p is InterpolationTagParser); var customIndex = pipeline.InlineParsers.FindIndex(p => p is MyCustomInlineParser); Assert.True(customIndex < interpolationIndex); }
public void It_Should_Be_Able_To_AddAfter_BlockParsers() { var builder = new ParserPipelineBuilder(); builder.AddAfter <SectionTagParser>(new MyCustomBlockParser()); var pipeline = builder.Build(); Assert.Contains(pipeline.BlockParsers, p => p is SectionTagParser); Assert.Contains(pipeline.BlockParsers, p => p is MyCustomBlockParser); var sectionIndex = pipeline.BlockParsers.FindIndex(p => p is SectionTagParser); var customIndex = pipeline.BlockParsers.FindIndex(p => p is MyCustomBlockParser); Assert.True(customIndex > sectionIndex); }
/// <summary> /// Builds an instance of the compilation settings from the builder /// </summary> /// <returns>The built compilation settings</returns> public override CompilerSettings BuildSettings() { var mergedGetters = DefaultSettings.DefaultValueGetters().MergeLeft(ValueGetters); return(new CompilerSettings( mergedGetters, TruthyChecks, EnumerationConverters, new TokenRendererPipeline <CompilerContext>(TokenRenderers), TemplateLoader, PartialTemplateLoader, MaxRecursionDepth.HasValue ? (MaxRecursionDepth.Value > 0 ? MaxRecursionDepth.Value : uint.MaxValue) : 256, IgnoreCaseOnKeyLookup, Parser ?? new CachedMustacheParser(), DefaultTags ?? new Core.Classes.Tags("{{", "}}"), ParserPipelineBuilder.Build(), CompilationSettings ?? CompilationSettings.GetDefaultRenderSettings(), SectionBlacklistTypes ?? DefaultSettings.DefaultSectionBlacklistTypes(), EncodingFunction ?? EncodingFunctions.WebUtilityHtmlEncoding)); }
/// <summary> /// Builds a RegistrySettings class with all the provided details /// </summary> /// <returns>The registry settings</returns> public override RendererSettings BuildSettings() { var mergedGetters = DefaultValueGetters().MergeLeft(ValueGetters); mergedGetters = mergedGetters .OrderBy(x => x.Key, TypeBySubclassAndAssignableImpl.TypeBySubclassAndAssignable()) .ToDictionary(item => item.Key, item => item.Value); return(new RendererSettings( mergedGetters, TruthyChecks, TemplateLoader, PartialTemplateLoader, MaxRecursionDepth.HasValue ? (MaxRecursionDepth.Value > 0 ? MaxRecursionDepth.Value : uint.MaxValue) : 256, RenderSettings ?? RenderSettings.GetDefaultRenderSettings(), EnumerationConverters, IgnoreCaseOnKeyLookup, Parser ?? new CachedMustacheParser(), new TokenRendererPipeline <Context>(TokenRenderers), DefaultTags ?? new Tags("{{", "}}"), ParserPipelineBuilder.Build(), SectionBlacklistTypes ?? DefaultSectionBlacklistTypes(), EncodingFunction ?? EncodingFunctions.WebUtilityHtmlEncoding)); }