AbstractTag class abstract

Abstract base class for all Liquid tags.

Subclass this to create custom tags. Override evaluateWithContext for synchronous evaluation or evaluateWithContextAsync for async evaluation.

Accessing Template Configuration

If your tag needs to re-parse content with the same delimiters as the parent template, access the config from the evaluator's context:

@override
dynamic evaluateWithContext(Evaluator evaluator, Buffer buffer) {
  final config = evaluator.context.config;
  final liquid = Liquid(config: config ?? LiquidConfig.standard);
  final result = liquid.renderString(content, evaluator.context.all());
  buffer.write(result);
}

See Environment.config for more details.

Constructors

AbstractTag(List<ASTNode> content, List<Filter> filters, [List<ASTNode> body = const []])
Constructs a new BaseTag with the given content, filters, and optional body.

Properties

args List<Identifier>
Returns a list of all identifiers in the tag's content.
no setter
body List<ASTNode>
The body nodes of the tag (for block tags).
getter/setter pair
content List<ASTNode>
The content nodes of the tag.
final
filters List<Filter>
The filters applied to the tag's output.
final
hashCode int
The hash code for this object.
no setterinherited
namedArgs List<NamedArgument>
Returns a list of all named arguments in the tag's content.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyFilters(dynamic value, Evaluator evaluator) → dynamic
Applies the tag's filters to the given value.
applyFiltersAsync(dynamic value, Evaluator evaluator) Future
evaluate(Evaluator evaluator, Buffer buffer) → dynamic
evaluateAsync(Evaluator evaluator, Buffer buffer) FutureOr
Evaluates the tag with proper scope management
evaluateContent(Evaluator evaluator) → dynamic
Evaluates the tag's content and returns the result as a string.
evaluateContentAsync(Evaluator eval) → dynamic
evaluateWithContext(Evaluator evaluator, Buffer buffer) → dynamic
Override this method in subclasses to implement tag behavior
evaluateWithContextAsync(Evaluator evaluator, Buffer buffer) Future
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preprocess(Evaluator evaluator) → void
Preprocesses the tag's content. Override this method for custom preprocessing.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited