public Expression Compile(IEnumerable<Expression> expressions, Expression parentContext)
        {
            try
            {
                if (expressions.Any() == false)
                {
                    return _emptyLambda;
                }
                if (expressions.IsOneOf<Expression, DefaultExpression>() == true)
                {
                    return _emptyLambda;
                }
                var compilationContext = new CompilationContext(_configuration);
                var expression = CreateExpressionBlock(expressions);
                expression = StaticReplacer.Replace(expression, compilationContext);
                expression = PartialBinder.Bind(expression, compilationContext);
                expression = IteratorBinder.Bind(expression, compilationContext);
                expression = BlockHelperFunctionBinder.Bind(expression, compilationContext);
                expression = DeferredSectionVisitor.Bind(expression, compilationContext);
                expression = HelperFunctionBinder.Bind(expression, compilationContext);
				expression = BoolishConverter.Convert(expression, compilationContext);
                expression = PathBinder.Bind(expression, compilationContext);
                expression = ContextBinder.Bind(expression, compilationContext, parentContext);
                return expression;
            }
            catch (Exception ex)
            {
                throw new HandlebarsCompilerException("An unhandled exception occurred while trying to compile the template", ex);
            }
        }
 public static Expression Bind(Expression body, CompilationContext context, Expression parentContext)
 {
     var writerParameter = Expression.Parameter(typeof(TextWriter), "buffer");
     var objectParameter = Expression.Parameter(typeof(object), "data");
     if (parentContext == null)
     {
         parentContext = Expression.Constant(null, typeof(BindingContext));
     }
     var newBindingContext = Expression.New(
          typeof(BindingContext).GetConstructor(
              new[] { typeof(object), typeof(TextWriter), typeof(BindingContext) }),
         new Expression[] { objectParameter, Expression.Call(new Func<TextWriter, TextWriter>(GetEncodedWriter).Method,writerParameter), parentContext });
     return Expression.Lambda<Action<TextWriter, object>>(
         Expression.Block(
             new [] { context.BindingContext },
             new Expression[] {
                 Expression.IfThenElse(
                     Expression.TypeIs(objectParameter, typeof(BindingContext)),
                     Expression.Assign(context.BindingContext, Expression.TypeAs(objectParameter, typeof(BindingContext))),
                     Expression.Assign(context.BindingContext, newBindingContext))
             }.Concat(
                 ((BlockExpression)body).Expressions
             )),
         new[] { writerParameter, objectParameter });
 }
 public static Expression Bind(Expression expr, CompilationContext context)
 {
     return new PartialBinder(context).Visit(expr);
 }
 private PartialBinder(CompilationContext context)
 {
     _context = context;
 }
 public static Expression Bind(Expression expr, CompilationContext context)
 {
     return new BlockHelperFunctionBinder(context).Visit(expr);
 }
 private BlockHelperFunctionBinder(CompilationContext context)
 {
     _context = context;
 }
 public static Expression Replace(Expression expr, CompilationContext context)
 {
     return new StaticReplacer(context).Visit(expr);
 }
 private StaticReplacer(CompilationContext context)
 {
     _context = context;
 }
 private DeferredSectionVisitor(CompilationContext context)
 {
     _context = context;
 }
 public static Expression Bind(Expression expr, CompilationContext context)
 {
     return new DeferredSectionVisitor(context).Visit(expr);
 }
		public static Expression Convert(Expression expr, CompilationContext context)
		{
			return new BoolishConverter(context).Visit(expr);
		}
		private BoolishConverter(CompilationContext context)
		{
			_context = context;
		}
 private IteratorBinder(CompilationContext context)
 {
     _context = context;
 }
 private PathBinder(CompilationContext context)
 {
     _context = context;
 }
 private IteratorBinder(CompilationContext context)
 {
     _context = context;
 }
 public static Expression Bind(Expression expr, CompilationContext context)
 {
     return(new IteratorBinder(context).Visit(expr));
 }