swap method
Using the supplied template and list of tag objects found within it and a the supplied formatter object, make all the substitutions and return the new string.
Implementation
String? swap(String template, List<Map<String, String>> tags,
DartamakerFormatter formatter) {
var str = template;
// Iterate through the tags
for (final tag in tags) {
final plugin = _pluginManager.byStringTagName(
tag[DartamakerConstants.tag],
tag[DartamakerConstants.params]!,
_cache)!;
// Calculate the replacement
final replacement = formatter.filter(plugin.apply());
if (replacement != null) {
// Cache the last-generated value for each tag
_cache.updateByStringTagName(tag[DartamakerConstants.tag], replacement);
// Switch the tag in the template for the replacement
str = str.replaceAll(tag[DartamakerConstants.original]!, replacement);
}
}
// Apply any post formatting specified by the formatter
return formatter.postCommit(str);
}