Interface IEvaluatesDomValueExpression
An object which evaluates an expression and returns a value which may be used by the DOM.
Namespace: ZptSharp.Tal
Assembly: ZptSharp.Abstractions.dll
Syntax
public interface IEvaluatesDomValueExpression
Methods
| Improve this Doc View SourceEvaluateExpressionAsync(String, ExpressionContext, CancellationToken)
Evaluates the expression asynchronously and returns the result.
Declaration
Task<DomValueExpressionResult> EvaluateExpressionAsync(string expression, ExpressionContext context, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | An expression which might be prefixed to indicate that it is to be treated as structure. |
ExpressionContext | context | Context. |
System.Threading.CancellationToken | cancellationToken | Cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<DomValueExpressionResult> | The expression result. |
Remarks
This method also deals with the differentiation between structure
and text
expressions. Structure expressions are inserted directly into the DOM without escaping or encoding.
Text expressions are treated explicitly as text and are encoded/escaped to ensure that they are not
accidentally treated as markup.
Expressions are treated as text by default. An expression is only treated as structure if:
- It is prefixed by a keyword
structure
and a single space, for examplestructure myExpression
- The expression result implements IGetsStructuredMarkup and the expression is NOT prefixed by
the keyword
text
and a single space, for exampletext myExpression
Apart from aborting the treatment of IGetsStructuredMarkup as structure, the text
prefix
keyword for expressions is redundant, as it is the default. It is supported though, for situations where you wish
to be explicit.