C# Class Scriban.TemplateContext

The template context contains the state of the page, the model.
Afficher le fichier Open project: lunet-io/scriban Class Usage Examples

Private Properties

Свойство Type Description
EnterFunction void
EnterLoop void
ExitFunction void
ExitLoop void
GetListAccessor IListAccessor
GetOrSetValue object
GetStoreForSet IEnumerable
GetValueInternal object
PopVariableScope void
PushVariableScope void
StepLoop bool

Méthodes publiques

Méthode Description
Evaluate ( ScriptNode scriptNode ) : object

Evaluates the specified script node.

Result is set to null when calling directly this method.

Evaluate ( ScriptNode scriptNode, bool aliasReturnedFunction ) : object

Evaluates the specified script node.

Result is set to null when calling directly this method.

GetDefaultBuiltinObject ( ) : ScriptObject

Gets a ScriptObject with all default builtins registered.

GetMemberAccessor ( object target ) : IMemberAccessor

Gets the member accessor for the specified object.

GetValue ( ScriptExpression target ) : object

Gets the value from the specified expression using the current ScriptObject bound to the model context.

PopGlobal ( ) : IScriptObject

Pops the previous model context.

PopOutput ( ) : string

Pops a previous output.

PopSourceFile ( ) : string

Pops the source file being executed.

PushGlobal ( IScriptObject scriptObject ) : void

Pushes a new model context accessible to the template.

PushOutput ( ) : void

Pushes a new output used for rendering the current template while keeping the previous output.

PushSourceFile ( string sourceFile ) : void

Pushes the source file path being executed. This should have enough information so that template loading/include can work correctly.

SetReadOnly ( ScriptVariable variable, bool isReadOnly = true ) : void

Sets the variable to read only.

This will not throw an exception if a previous variable was readonly.

SetValue ( ScriptExpression target, object value ) : void

Sets the target expression with the specified value.

SetValue ( ScriptVariable variable, object value, bool asReadOnly ) : void

Sets the variable with the specified value.

TemplateContext ( ) : System

Initializes a new instance of the TemplateContext class.

TemplateContext ( ScriptObject builtin ) : System

Initializes a new instance of the TemplateContext class.

Write ( SourceSpan span, object textAsObject ) : void

Writes an object value to the current Output.

Write ( string text ) : void

Writes the text to the current Output

Private Methods

Méthode Description
EnterFunction ( ScriptNode caller ) : void
EnterLoop ( ScriptLoopStatementBase loop ) : void
ExitFunction ( ) : void
ExitLoop ( ) : void
GetListAccessor ( object target ) : IListAccessor
GetOrSetValue ( ScriptExpression targetExpression, object valueToSet, bool setter, int level ) : object
GetStoreForSet ( ScriptVariable variable ) : IEnumerable
GetValueInternal ( ScriptVariable variable ) : object
PopVariableScope ( ScriptVariableScope scope ) : void
PushVariableScope ( ScriptVariableScope scope ) : void
StepLoop ( ) : bool

Method Details

Evaluate() public méthode

Evaluates the specified script node.
Result is set to null when calling directly this method.
public Evaluate ( ScriptNode scriptNode ) : object
scriptNode Scriban.Runtime.ScriptNode The script node.
Résultat object

Evaluate() public méthode

Evaluates the specified script node.
Result is set to null when calling directly this method.
public Evaluate ( ScriptNode scriptNode, bool aliasReturnedFunction ) : object
scriptNode Scriban.Runtime.ScriptNode The script node.
aliasReturnedFunction bool if set to true and a function would be evaluated as part of this node, return the object function without evaluating it.
Résultat object

GetDefaultBuiltinObject() public static méthode

Gets a ScriptObject with all default builtins registered.
public static GetDefaultBuiltinObject ( ) : ScriptObject
Résultat ScriptObject

GetMemberAccessor() public méthode

Gets the member accessor for the specified object.
public GetMemberAccessor ( object target ) : IMemberAccessor
target object The target object to get a member accessor.
Résultat IMemberAccessor

GetValue() public méthode

Gets the value from the specified expression using the current ScriptObject bound to the model context.
public GetValue ( ScriptExpression target ) : object
target ScriptExpression The expression
Résultat object

PopGlobal() public méthode

Pops the previous model context.
Unexpected PopGlobal() not matching a PushGlobal
public PopGlobal ( ) : IScriptObject
Résultat IScriptObject

PopOutput() public méthode

Pops a previous output.
public PopOutput ( ) : string
Résultat string

PopSourceFile() public méthode

Pops the source file being executed.
Cannot PopSourceFile more than PushSourceFile
public PopSourceFile ( ) : string
Résultat string

PushGlobal() public méthode

Pushes a new model context accessible to the template.
public PushGlobal ( IScriptObject scriptObject ) : void
scriptObject IScriptObject The script object.
Résultat void

PushOutput() public méthode

Pushes a new output used for rendering the current template while keeping the previous output.
public PushOutput ( ) : void
Résultat void

PushSourceFile() public méthode

Pushes the source file path being executed. This should have enough information so that template loading/include can work correctly.
public PushSourceFile ( string sourceFile ) : void
sourceFile string The source file.
Résultat void

SetReadOnly() public méthode

Sets the variable to read only.
This will not throw an exception if a previous variable was readonly.
If variable is null
public SetReadOnly ( ScriptVariable variable, bool isReadOnly = true ) : void
variable ScriptVariable The variable.
isReadOnly bool if set to true the variable will be set to readonly.
Résultat void

SetValue() public méthode

Sets the target expression with the specified value.
If target is null
public SetValue ( ScriptExpression target, object value ) : void
target ScriptExpression The target expression.
value object The value.
Résultat void

SetValue() public méthode

Sets the variable with the specified value.
If variable is null If an existing variable is already read-only
public SetValue ( ScriptVariable variable, object value, bool asReadOnly ) : void
variable ScriptVariable The variable.
value object The value.
asReadOnly bool if set to true the variable set will be read-only.
Résultat void

TemplateContext() public méthode

Initializes a new instance of the TemplateContext class.
public TemplateContext ( ) : System
Résultat System

TemplateContext() public méthode

Initializes a new instance of the TemplateContext class.
public TemplateContext ( ScriptObject builtin ) : System
builtin ScriptObject The builtin object used to expose builtin functions, default is .
Résultat System

Write() public méthode

Writes an object value to the current Output.
public Write ( SourceSpan span, object textAsObject ) : void
span Scriban.Parsing.SourceSpan The span of the object to render.
textAsObject object The text as object.
Résultat void

Write() public méthode

Writes the text to the current Output
public Write ( string text ) : void
text string The text.
Résultat void