Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/printers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ function embed(path: AstPath<NodeType>, options: PluginOptions<NodeType>) {
);

const printed = printTemplateTag(content);

if (options.templateExportDefault && path.parent?.type === 'Program') {
printed.unshift('export ', 'default ');
}

saveCurrentPrintOnSiblingNode(path, printed);
return printed;
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ exports[`config > templateExportDefault: true > it formats ../cases/gjs/one-line

exports[`config > templateExportDefault: true > it formats ../cases/gjs/preceded-by-object.gjs 1`] = `
"const foo = {};
<template>hello</template>
export default <template>hello</template>
"
`;

Expand Down Expand Up @@ -276,12 +276,12 @@ export default Route(
`;

exports[`config > templateExportDefault: true > it formats ../cases/gjs/simple.gjs 1`] = `
"<template>what</template>
"export default <template>what</template>
"
`;

exports[`config > templateExportDefault: true > it formats ../cases/gjs/simple-with-tag.gjs 1`] = `
"<template>
"export default <template>
<h1>what</h1>
</template>

Expand Down Expand Up @@ -475,7 +475,7 @@ export default class PooComponent extends Component {
`;

exports[`config > templateExportDefault: true > it formats ../cases/gts/issue-191-b.gts 1`] = `
"<template>💩</template>
"export default <template>💩</template>
"
`;

Expand Down