buildAttributeMap function

String buildAttributeMap(
  1. Map<String, dynamic> global,
  2. BuilderConfig config, [
  3. int depth = 1
])

Parses all tokens and parses all attributes to dart readable format.

Implementation

String buildAttributeMap(
  Map<String, dynamic> global,
  BuilderConfig config, [
  int depth = 1,
]) {
  String recursiveMap(Map<String, dynamic> map, depth) {
    var output = '';
    for (final key in map.keys) {
      final attr = map[key] as Map<String, dynamic>;
      final dynamic value;
      if (attr.keys.contains('value') && attr.keys.contains('type')) {
        value = _parseAttribute(attr, config: config, indentationLevel: depth);
      } else {
        value = '{\n${recursiveMap(attr, depth + 1)}${'  ' * depth}}';
      }
      output += '${'  ' * depth}\'$key\': $value,\n';
    }
    return output;
  }

  return '{\n${recursiveMap(global, depth)}}';
}