interpolate static method

String interpolate(
  1. String input,
  2. ConsumerSupplierFunction<String, String?> callback
)

Interpolate {} tokens in the input string

Implementation

static String interpolate(String input, ConsumerSupplierFunction<String, String?> callback)
{
  String matchCallback(Match match)
  {
    String key = match.group(1)!;
    return callback(key) ?? ella.EMPTY_STRING;
  }

  return input.replaceAllMapped(_INTERPOLATE_REGEXP, matchCallback);
}