Пример #1
0
        public override void AfterVisit(Statement statement)
        {
            var childEmitter = EmitterNode.Many(LeaveScope());
            var listEmitter = _expressionVisitor.LeaveTreeScope(statement.Expression, childEmitter);

            Scope.Add(listEmitter);
        }
Пример #2
0
        public override bool BeforeVisit(Statement statement)
        {
            _expressionVisitor.EnterScope(statement.Expression);
            EnterScope();

            return true;
        }
		public bool BeforeVisit(Statement statement)
		{
			var expression = statement.Expression;

			var iterationExpression = expression as IterationExpression;
			if (iterationExpression != null)
			{
				var scope = new Scope();
				_scopes.Push(scope);

				var visitor = new EmitExpressionVisitor(_dataBinder, new NullHelperBinder());
				iterationExpression.Expression.Accept(visitor);

				var context = _dataBinder.Context();
				IEvaluator<IEnumerable> evaluator;
				if (!context.TryCreateEvaluation(out evaluator))
					return false;

				Action<TextWriter, IDataContext, IRenderingContext> ext = (writer, dataContext, renderingContext) =>
				{
					var items = evaluator.Evaluate(dataContext);
					foreach (var item in items)
					{

					}
				};
				scope.Elements.Add(ext);

				//IEvaluator<string> evaluator;
				//if (result.TryCreateEvaluation(out evaluator))
				//{
				//	scope.Elements.Add((writer, dataContext, renderingContext) =>
				//	{
				//		var value = evaluator.Evaluate(dataContext);
				//		writer.Write(value);
				//	});
				//}
			}

			return true;
		}
Пример #4
0
 private static void AssertDynamic(Statement expected, Statement actual)
 {
     HandlebarsExpressionAssert.AssertExpression(expected.Expression, actual.Expression);
     AssertNodeList(expected.ChildNodes, actual.ChildNodes);
 }
Пример #5
0
 public virtual void AfterVisit(Statement statement)
 {
 }
Пример #6
0
 public virtual bool BeforeVisit(Statement statement)
 {
     statement.Expression.Accept(_expressionVisitor);
     return false;
 }
		public void AfterVisit(Statement statement)
		{
			var scope = _scopes.Peek();
			var expression = statement.Expression;

			var iterationExpression = expression as IterationExpression;
			if (iterationExpression != null)
			{
				throw new NotImplementedException();
			}

			var conditionalExpression = expression as ConditionalExpression;
			if (conditionalExpression != null)
			{
				throw new NotImplementedException();
			}

			var callHelperExpression = expression as CallHelperExpression;
			if (callHelperExpression != null)
			{
				throw new NotImplementedException();
			}

			var memberExpression = expression as MemberExpression;
			if (memberExpression != null)
			{
				var result = _dataBinder.Property(memberExpression.Name);
				IEvaluator<string> evaluator;
				if (result.TryCreateEvaluation(out evaluator))
				{
					scope.Elements.Add((writer, dataContext, renderingContext) =>
					{
						var value = evaluator.Evaluate(dataContext);
						writer.Write(value);
					});
				}
				return;
			}

			throw new NotImplementedException();
		}