call<V> method

String call<V>(
  1. Map<String?, V> subs
)

Perform interpolation on early parsed string template with subs

Implementation

String call<V>(Map<String?, V> subs) {

	final subCopy = {}..addAll(_defaultVal)..addAll(subs);

	final ret = StringBuffer();

	//Assemble the result string from segments and substitutions
	int index = 0;
	for(final unsub in _subs){
		ret.write(_bodySegs[index++]);
		ret.write(subCopy[unsub] ?? subCopy[null] ??
					(
						//If no placeholder specified
						//throw an Exception
						throw FormatException("No match with key \"$unsub\" at "
										   "${formatLocation(format,
										   					 RegExp(unsub))} "
						   					"and no placeholder specified")
					)
				);
	}
	return (ret..write(_bodySegs[index])).toString();
}