public static BlockAccumulatorContext Create(Expression item, HandlebarsConfiguration configuration)
 {
     BlockAccumulatorContext context = null;
     if (IsConditionalBlock(item))
     {
         context = new ConditionalBlockAccumulatorContext(item);
     }
     else if (IsPartialBlock(item))
     {
         context = new PartialBlockAccumulatorContext(item);
     }
     else if (IsBlockHelper(item, configuration))
     {
         context = new BlockHelperAccumulatorContext(item);
     }
     else if (IsIteratorBlock(item))
     {
         context = new IteratorBlockAccumulatorContext(item);
     }
     else if (IsDeferredBlock(item))
     {
         context = new DeferredBlockAccumulatorContext(item);
     }
     return context;
 }
        public static BlockAccumulatorContext Create(Expression item, HandlebarsConfiguration configuration)
        {
            BlockAccumulatorContext context = null;

            if (IsConditionalBlock(item))
            {
                context = new ConditionalBlockAccumulatorContext(item);
            }
            else if (IsPartialBlock(item))
            {
                context = new PartialBlockAccumulatorContext(item);
            }
            else if (IsBlockHelper(item, configuration))
            {
                context = new BlockHelperAccumulatorContext(item);
            }
            else if (IsIteratorBlock(item))
            {
                context = new IteratorBlockAccumulatorContext(item);
            }
            else if (IsDeferredBlock(item))
            {
                context = new DeferredBlockAccumulatorContext(item);
            }
            return(context);
        }
Beispiel #3
0
        public static BlockAccumulatorContext Create(Expression item, Expression parentItem, ICompiledHandlebarsConfiguration configuration)
        {
            BlockAccumulatorContext context = null;

            if (IsConditionalBlock(item))
            {
                context = new ConditionalBlockAccumulatorContext(item);
            }
            else if (IsPartialBlock(item))
            {
                context = new PartialBlockAccumulatorContext(item);
            }
            else if (IsIteratorBlock(item))
            {
                context = new IteratorBlockAccumulatorContext(item);
            }
            else if (IsBlockHelper(item, configuration))
            {
                context = new BlockHelperAccumulatorContext(item);
            }
            else if (IsDetachedClosingElement(item, parentItem, out var closingElement))
            {
                throw new HandlebarsCompilerException($"A closing element '{closingElement}' was found without a matching open element");
            }

            return(context);
        }