Skip to content
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

Formatting in inline script tags does not keep indents #69

Open
kareljan opened this issue Sep 24, 2020 · 3 comments
Open

Formatting in inline script tags does not keep indents #69

kareljan opened this issue Sep 24, 2020 · 3 comments

Comments

@kareljan
Copy link

I have some problem with the formatting when I have an inline script tag.
When I have this in my file:

<div>
    <script>
        const myVar = "test;
        if(myVar == 'test'){
            console.log("hello");
        }
    </script>
</div>

I get this:

<div>
    <script>
const myVar = "test;
if(myVar == 'test'){
console.log("hello");
}
    </script>
</div>

So the script tags stay on the correct indentation. But everything between the tags loses all indentation.
Am I the only one?

@ianshea
Copy link

ianshea commented Nov 13, 2020

I've had this issue too and been fiddling with this annoyance for a bit. I found this gem that's worked for me:

<!-- parse-ignore-start -->
<script>
        const myVar = "test;
        if(myVar == 'test'){
            console.log("hello");
        }
    </script>
<!-- parse-ignore-end -->

I don't like having HTML comments in my code like this, but when using a Twig comment syntax {# parse-ignore-end #} it adds an extra "d" onto the word "end" every time I save. While hilarious, it is inconvenient.

@JPustkuchen
Copy link

Thank you @ianshea - I can 100% confirm this. Anyway it would be wonderful if vscode-twig-language-2 could also format script contents! :)

@sanderjn
Copy link

sanderjn commented Aug 8, 2022

I'd love to see this as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants