replaceWordsInFile static method
Implementation
static String replaceWordsInFile({
required String fileString,
}) {
while (fileString.contains('{{')) {
final start = fileString.indexOf('{{');
final end = fileString.indexOf('}}');
String? term = fileString.substring(start + 2, end);
String? word = term.split('.')[0];
String? extension;
if (term.split('.').length > 1) extension = term.split('.')[1];
if (!_containsWord(word)) {
throw Exception('essa variavel não é aceita "$word"');
}
word = _replaceWordWithOptions(word);
if (extension != null) {
word = _recase(word!, extension);
if (word == null) {
throw Exception('extenção não aceita "$extension"');
}
}
fileString = fileString.replaceFirst('{{$term}}', word!);
}
return fileString;
}