public void PushNewScope(BlockNode blockNode, Type modelType) { this.scopeStack.AddFirst(new SuperSimpleTemplateParserScope { Block = blockNode, ModelType = modelType }); }
/// <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() }; }
/// <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 }; }
/// <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()); }
/// <summary> /// Create a sequential block of nodes /// </summary> public static BlockNode Block(params SyntaxTreeNode[] nodes) { var block = new BlockNode(); block.AddRange(nodes); return block; }
public static SyntaxTreeNode Helper(HelperExpressionNode helperExpression, BlockNode block, SourceLocation location) { return new HelperBlockNode { Location = location, HelperExpression = helperExpression, Block = block }; }