A node that contains a sequence of other nodes
Inheritance: SyntaxTreeNode
 public void PushNewScope(BlockNode blockNode, Type modelType)
 {
     this.scopeStack.AddFirst(new SuperSimpleTemplateParserScope
     {
         Block = blockNode,
         ModelType = modelType
     });
 }
Example #2
0
 /// <summary>
 /// Iterate a collection and execute the body block scoped to each item in the collection.
 /// Optionally execute an empty block when there are no items to iterate
 /// </summary>
 /// <param name="collectionExpression">expression to load the collection</param>
 /// <param name="body">Block to execute in the scope of each item</param>
 /// <param name="emptyBody">Block to execute when there are no items in the collection</param>
 public static IterateNode Iterate(ExpressionNode collectionExpression, BlockNode body, BlockNode emptyBody = null)
 {
     return new IterateNode
     {
         Collection = collectionExpression,
         Body = body,
         EmptyBody = emptyBody ?? SyntaxTree.Block()
     };
 }
Example #3
0
 /// <summary>
 /// Evaluates an expression and chooses between two blocks based on the truthy-ness of the result
 /// </summary>
 /// <param name="expression">The expression to evaluate</param>
 /// <param name="trueBlock">The block to execute when the expression is true</param>
 /// <param name="falseBlock">The block to evaluate when the expression is false</param>
 /// <returns></returns>
 public static ConditionalNode Conditional(ExpressionNode expression, BlockNode trueBlock, BlockNode falseBlock = null)
 {
     return new ConditionalNode
     {
         Expression = expression,
         TrueBlock = trueBlock,
         FalseBlock = falseBlock
     };
 }
Example #4
0
        /// <summary>
        /// Create a sequential block of nodes
        /// </summary>
        public static BlockNode Block(SourceLocation location, params SyntaxTreeNode[] nodes)
        {
            var block = new BlockNode
            {
	            Location = location
            };
            block.AddRange(nodes);
            return block;
        }
 public void PushNewScope(BlockNode blockNode)
 {
     this.PushNewScope(blockNode, this.CurrentTypeInScope());
 }
Example #6
0
 /// <summary>
 /// Create a sequential block of nodes
 /// </summary>
 public static BlockNode Block(params SyntaxTreeNode[] nodes)
 {
     var block = new BlockNode();
     block.AddRange(nodes);
     return block;
 }
Example #7
0
	    public static SyntaxTreeNode Helper(HelperExpressionNode helperExpression, BlockNode block, SourceLocation location)
	    {
		    return new HelperBlockNode
		    {
				Location = location,
				HelperExpression = helperExpression,
				Block = block
		    };
	    }