replace property

JsonCraftFormatter get replace

Implementation

static JsonCraftFormatter get replace => JsonCraftFormatter(
      name: 'replace',
      formatter: (value, param, getValue) {
        final partes = param?.split(',') ?? [];
        for (final p in partes) {
          final keyValue = p.split(':');
          if (keyValue.length == 2) {
            value = value.replaceAll(
              '{${keyValue[0]}}',
              getValue(keyValue[1]),
            );
          }
        }
        return value;
      },
    );