eval function
Implementation
String eval(String value, World world) {
final pattern = RegExp(r'{{(?!{{)(?!\|)([A-z.]*)(?:\|([A-z.]*))?(?<!}})}}');
var text = value;
final matches = pattern.allMatches(text);
for (var match in matches) {
final objName = match.group(1)!;
final from = match.group(0)!;
final reCase = match.group(2);
var to = getArg<String>(objName, world.objects);
if (to.contains(pattern)) to = eval(to, world);
if (reCase != null) {
switch (reCase) {
case 'pascalCase':
to = ReCase(to).pascalCase;
break;
case 'camelCase':
to = ReCase(to).camelCase;
break;
case 'constantCase':
to = ReCase(to).constantCase;
break;
case 'dotCase':
to = ReCase(to).dotCase;
break;
case 'headerCase':
to = ReCase(to).headerCase;
break;
case 'paramCase':
to = ReCase(to).paramCase;
break;
case 'pathCase':
to = ReCase(to).pathCase;
break;
case 'sentenceCase':
to = ReCase(to).sentenceCase;
break;
case 'snakeCase':
to = ReCase(to).snakeCase;
break;
case 'titleCase':
to = ReCase(to).titleCase;
break;
}
}
text = text.replaceFirst(from, to);
}
return text;
}