prettier-plugin-ember-template-tag
Version:
A prettier plugin for formatting Ember template tags
18 lines (16 loc) • 423 B
text/typescript
import type { doc } from 'prettier';
/**
* Flattens the given doc into a string array, tossing line breaks, etc, for
* analysis.
*/
export function flattenDoc(doc: doc.builders.Doc): string[] {
if (Array.isArray(doc)) {
return doc.flatMap(flattenDoc);
} else if (typeof doc === 'string') {
return [doc];
} else if ('contents' in doc) {
return flattenDoc(doc.contents);
} else {
return [];
}
}