Skip to content

Commit f299c6a

Browse files
committed
feat: 🎸 support markup preprocessing with no tags
1 parent 45e9fea commit f299c6a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎src/autoProcess.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type AutoPreprocessOptions = {
4747
pug?: TransformerOptions<Options.Pug>;
4848
globalStyle?: Options.GlobalStyle | boolean;
4949
replace?: Options.Replace;
50+
5051
// workaround while we don't have this
5152
// https://github.com/microsoft/TypeScript/issues/17867
5253
[languageName: string]:
@@ -212,7 +213,7 @@ export function autoPreprocess(
212213

213214
/** If no <template> was found, just return the original markup */
214215
if (!templateMatch) {
215-
return { code: content };
216+
return markupTransformer({ content, attributes: {}, filename });
216217
}
217218

218219
const [fullMatch, attributesStr, templateCode] = templateMatch;

‎test/autoProcess/autoProcess.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,21 @@ describe('options', () => {
186186
'<script lang="tomatoScript">tomato</script>',
187187
);
188188
});
189+
190+
it('should be able to use default markup language with template tags', async () => {
191+
const input = `potato`;
192+
193+
const opts = autoPreprocess({
194+
defaults: {
195+
markup: 'potatoScript',
196+
},
197+
potatoScript({ content }) {
198+
return { code: content.replace('potato', 'french-fries') };
199+
},
200+
});
201+
202+
const preprocessed = await preprocess(input, opts);
203+
204+
expect(preprocessed.toString()).toContain('french-fries');
205+
});
189206
});

0 commit comments

Comments
 (0)