parse static method
Implementation
static String parse(
String template,
List<TemplateModel> models,
) {
if (template.isEmpty) {
return '';
}
if (models.isEmpty) {
return template;
}
final variableList = regExp.allMatches(template).toList();
if (variableList.isNotEmpty) {
for (final variable in variableList) {
var key = variable[1].toString();
template = template.replaceAll(key, replaceCacheValue);
key = key.replaceAll('{{', '').replaceAll('}}', '');
key = '{{${key.trim()}}}';
template = template.replaceAll(replaceCacheValue, key);
}
}
for (final model in models) {
if (model.variable.trim().isNotEmpty) {
final key = '{{${model.variable.trim()}}}';
template = template.replaceAll(key, model.value);
}
}
return template;
}