-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Is your feature request related to a problem? Please describe.
while writing the preprocessor recipe (https://github.com/svelte-society/recipes-mvp/blob/master/build-setup.md#how-to-make-a-pre-processor-that-makes-it-possible-to-use-pugjade) and livecoding for a talk, i realized it is too hard to split out the script/style tags and then too easy to forget to stitch them back together again. this is a pretty common task for markup preprocessing and i think it would be very low cost to add it to svelte since it only involves optional code?
Describe the solution you'd like
offer a utility for preprocessing that kinda works like this:
import {utils} from "svelte/compiler"
(async function () {
const result = await svelte.preprocess(file, {
markup: ({ content }) => {
code = utils.modifyTemplate(template => {
// no need to mess with stripping and restitching style and script tags
return pug.render(template)
})
return { code };
},
});
})();
we offer this for script and style tags, it feels weird that we don't offer it for markup right?
Describe alternatives you've considered
do nothing, or
could also just consider an alternative template
api:
import {utils} from "svelte/compiler"
(async function () {
const result = await svelte.preprocess(file, {
template: ({ content }) => {
return { code: pug.render(template) };
},
});
})();
How important is this feature to you?
nice to have