C# Class Veil.Parser.SyntaxTree

Factory methods for creating syntax tree nodes
Show file Open project: namics/TerrificNet

Public Methods

Method Description
Block ( SourceLocation location ) : BlockNode

Create a sequential block of nodes

Conditional ( ExpressionNode expression, SourceLocation location, BlockNode trueBlock, BlockNode falseBlock = null ) : ConditionalNode

Evaluates an expression and chooses between two blocks based on the truthy-ness of the result

Extend ( string templateName, SourceLocation location, SyntaxTreeNode>.IDictionary overrides = null ) : ExtendTemplateNode

Defines a template that extends another template e.g. MasterPages Extend nodes must be the root of a syntax tree

Flush ( SourceLocation location ) : FlushNode

Flushes the TextWriter. Used to optimize responses in web applications.

Helper ( HelperExpressionNode helperExpression, BlockNode block, SourceLocation location ) : SyntaxTreeNode
Include ( string templateName, ExpressionNode modelExpression, SourceLocation location ) : IncludeTemplateNode

Execute another template in the scope of the provided model

Iterate ( ExpressionNode collectionExpression, SourceLocation location, BlockNode body, BlockNode emptyBody = null ) : IterateNode

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

Override ( string overrideName, SourceLocation location, bool isOptional = false ) : OverridePointNode

Defines a point in a template that can be overridden when the template is extended.

Override ( string overrideName, SyntaxTreeNode defaultContent, SourceLocation location ) : OverridePointNode

Defines an optional point in a template that can be overridden when the template is extended. If the point is not overridden then the specified content is used by default

ScopeNode ( ExpressionNode modelToScopeTo, SyntaxTreeNode node, SourceLocation location ) : ScopedNode

Scopes a node to a new model

WriteExpression ( ExpressionNode expression, SourceLocation location, bool htmlEncode = false ) : WriteExpressionNode

Evaluate an expression and write the value to the TextWriter

WriteString ( string content, SourceLocation location ) : WriteLiteralNode

Write a string literal to the TextWriter

Method Details

Block() public static method

Create a sequential block of nodes
public static Block ( SourceLocation location ) : BlockNode
location SourceLocation
return Veil.Parser.Nodes.BlockNode

Conditional() public static method

Evaluates an expression and chooses between two blocks based on the truthy-ness of the result
public static Conditional ( ExpressionNode expression, SourceLocation location, BlockNode trueBlock, BlockNode falseBlock = null ) : ConditionalNode
expression ExpressionNode The expression to evaluate
location SourceLocation
trueBlock Veil.Parser.Nodes.BlockNode The block to execute when the expression is true
falseBlock Veil.Parser.Nodes.BlockNode The block to evaluate when the expression is false
return Veil.Parser.Nodes.ConditionalNode

Extend() public static method

Defines a template that extends another template e.g. MasterPages Extend nodes must be the root of a syntax tree
public static Extend ( string templateName, SourceLocation location, SyntaxTreeNode>.IDictionary overrides = null ) : ExtendTemplateNode
templateName string The name of the template to extend. It will be loaded from the
location SourceLocation
overrides SyntaxTreeNode>.IDictionary A set of overrides for the defined in the template being extended.
return Veil.Parser.Nodes.ExtendTemplateNode

Flush() public static method

Flushes the TextWriter. Used to optimize responses in web applications.
public static Flush ( SourceLocation location ) : FlushNode
location SourceLocation
return FlushNode

Helper() public static method

public static Helper ( HelperExpressionNode helperExpression, BlockNode block, SourceLocation location ) : SyntaxTreeNode
helperExpression HelperExpressionNode
block Veil.Parser.Nodes.BlockNode
location SourceLocation
return SyntaxTreeNode

Include() public static method

Execute another template in the scope of the provided model
public static Include ( string templateName, ExpressionNode modelExpression, SourceLocation location ) : IncludeTemplateNode
templateName string The name of the template to execute. It will be loaded from the
modelExpression ExpressionNode An expression for the model to be used as the root scope when executing the template
location SourceLocation
return Veil.Parser.Nodes.IncludeTemplateNode

Iterate() public static method

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
public static Iterate ( ExpressionNode collectionExpression, SourceLocation location, BlockNode body, BlockNode emptyBody = null ) : IterateNode
collectionExpression ExpressionNode expression to load the collection
location SourceLocation
body Veil.Parser.Nodes.BlockNode Block to execute in the scope of each item
emptyBody Veil.Parser.Nodes.BlockNode Block to execute when there are no items in the collection
return Veil.Parser.Nodes.IterateNode

Override() public static method

Defines a point in a template that can be overridden when the template is extended.
public static Override ( string overrideName, SourceLocation location, bool isOptional = false ) : OverridePointNode
overrideName string The name of the override which must match that specified in the overriding template
location SourceLocation
isOptional bool Indicates whether an exception should be thrown if the override is missing
return Veil.Parser.Nodes.OverridePointNode

Override() public static method

Defines an optional point in a template that can be overridden when the template is extended. If the point is not overridden then the specified content is used by default
public static Override ( string overrideName, SyntaxTreeNode defaultContent, SourceLocation location ) : OverridePointNode
overrideName string The name of the override which must match that specified in the overriding template
defaultContent SyntaxTreeNode The content to use when the point is not overridden
location SourceLocation
return Veil.Parser.Nodes.OverridePointNode

ScopeNode() public static method

Scopes a node to a new model
public static ScopeNode ( ExpressionNode modelToScopeTo, SyntaxTreeNode node, SourceLocation location ) : ScopedNode
modelToScopeTo ExpressionNode An expression that evaluates to the model to scope to
node SyntaxTreeNode The node to execute in the new scope
location SourceLocation
return Veil.Parser.Nodes.ScopedNode

WriteExpression() public static method

Evaluate an expression and write the value to the TextWriter
public static WriteExpression ( ExpressionNode expression, SourceLocation location, bool htmlEncode = false ) : WriteExpressionNode
expression ExpressionNode The expression to be written
location SourceLocation
htmlEncode bool Indicates whether the content should be html encoded before being written
return WriteExpressionNode

WriteString() public static method

Write a string literal to the TextWriter
public static WriteString ( string content, SourceLocation location ) : WriteLiteralNode
content string The string to be written
location SourceLocation
return Veil.Parser.Nodes.WriteLiteralNode