apply method

  1. @override
Future<String> apply(
  1. String content,
  2. Map<String, dynamic> context
)
override

Implementation

@override
Future<String> apply(String content, Map<String, dynamic> context) async {
  String result = content;

  // Process @lang directives
  result = result.replaceAllMapped(_langRegex, (match) {
    final key = match.group(2)!;
    final options = match.group(3);

    return _processLangDirective(key, options, context);
  });

  // Process @choice directives
  result = result.replaceAllMapped(_choiceRegex, (match) {
    final key = match.group(2)!;
    final countExpr = match.group(3)!;
    final options = match.group(4);

    return _processChoiceDirective(key, countExpr, options, context);
  });

  // Process @field directives
  result = result.replaceAllMapped(_fieldRegex, (match) {
    final key = match.group(2)!;
    final options = match.group(3);

    return _processFieldDirective(key, options, context);
  });

  return result;
}