format method

  1. @override
String format({
  1. String trailing = '',
  2. String postStartBraces = '',
  3. String preEndBraces = '',
})
override

returns the name of the file with formatting to mustache

trailing gets appended to the end of the name AFTER wrapping the name with braces & formatting but BEFORE wrapping with the section tag

postStartBraces & preEndBraces gets prepended to the name BEFORE wrapping the name with braces & formatting

Implementation

@override
String format({
  String trailing = '',
  String postStartBraces = '',
  String preEndBraces = '',
}) {
  var result = renameWith ?? originalName;

  if (result == Constants.kIndexValue) {
    result = '.';
  }

  result = '$postStartBraces$result$preEndBraces';

  if (tag != null) {
    result = tag!.wrap(result, braceCount: braces);
  } else {
    final startBraces = '{' * braces;
    final endBraces = '}' * braces;
    result = '$startBraces$result$endBraces';
  }

  result = '$prefix$result$suffix$trailing';

  final section = this.section?.object?.name ?? this.section?.string;
  final isInverted = this.section?.object?.isInverted ?? false;

  if (section != null) {
    String start;
    String end;

    if (isInverted) {
      start = MustacheTag.ifNot.wrap(section);
    } else {
      start = MustacheTag.if_.wrap(section);
    }

    end = MustacheTag.endIf.wrap(section);

    result = '$start$result$end';
  }

  return result;
}