-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple <script> blocks #6387
Comments
This may not be quite what you're looking for but https://svelte.dev/repl/6d30c0c7269740acab724a3e0db9a189?version=3.38.2 This may be of limited value since the additional |
The given arguments are not strong enough to make this a consideration. If you use a preprocessor, you can do what you want but you are also on your own so to speak. If the script language is not JavaScript, you can rearrange the preprocessor execution order so that the html processor runs last, at which point the script will be preprocessed. |
Is your feature request related to a problem? Please describe.
I'm writing a custom preprocessor. It processes the entire file (i.e. markup) and needs to generate some JavaScript. It does that by outputting a new <script> block. Unfortunately, if the svelte file already has a <script> block, I get an error telling me that a page is only allowed to have a single <script> block. This sounds like an unnecessary restriction.
Describe the solution you'd like
A svelte page should be allowed to have any number of <script> blocks. The same should probably go for <style> blocks.
Describe alternatives you've considered
I've considered just checking if the current page already has a <script> block and just injecting JavaScript into that block. The problem is that the existing <script> block may specify coffeescript or some other preprocessor already. Then I'd have to inject coffeescript instead of plain JavaScript. And what happens if there's some other language used in the future?
How important is this feature to you?
I can work around the problem for now, but I think that a successful solution would require my suggestion be implemented.
The text was updated successfully, but these errors were encountered: