Stillat / vscode-antlers-language-server

Provides rich language features for Statamic's Antlers templating language, including code completions, syntax highlighting, and more.
https://antlers.dev
MIT License
36 stars 3 forks source link

Ability to disable formatting of a few lines, instead of a whole file #51

Closed duncanmcclean closed 1 year ago

duncanmcclean commented 1 year ago

Which Antlers Toolbox products are you requesting a feature for?

Is your feature request related to a problem? Please describe.

Sometimes I run into formatting issues when doing Antlers stuff inside a <script> tag in an Antlers view.

For example: here's something I'm doing right now which messes up with the formatting for all the JS code under it:

<script>
    // Set value of 'building' field to the current building
    {{ nav from="/locations" select="title|slug" :slug:is="segment_2" }}
        if (window.location.includes('{{ slug }}')) {
            document.getElementById('contactFormModalForm').building.value = '{{ title }}';
        }
    {{ /nav }}

    // ...
</script>

You could argue that Antlers could probably not do the weird indentation formatting it does right now instead of just ignoring it...

Describe the solution you'd like Right now I can disable formatting for the entire Antlers view which I don't always want to do.

Ideally, I'd like a way to ignore formatting between specific lines. I'm not 100% sure how this would work but maybe with a code comment at the top of the block, then one at the end to mark the start/end for the block where no formatting should take place.

Describe alternatives you've considered Disabling formatting for the entire Antlers view.

JohnathonKoster commented 1 year ago

The formatters will now ignore scripts containing Antlers tag pairs as of 2.3.9