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

Strange replacement on format #67

Closed johncarter- closed 1 year ago

johncarter- commented 1 year ago

Describe the bug Formatting this chunk:

{{ if author:avatar }}
    {{ responsive src="{author:avatar}" class="object-cover w-full h-full" style="object-position: '{author:avatar:focus|background_position}'" glide:width="250" }}
{{ else }}
    <img class="object-cover w-full h-full" src="{{ author:email | gravatar }}" alt="">
{{ /if }}

Results in this oddity:

{{ if author:avatar }}
    {{ responsive src="{id}cb6788ba8c9" class="object-cover w-full h-full" style="object-position: '{id}da269c98e209474f73886de2f9322cb7xxxxx'" glide:width="250" }}
{{ else }}
    <img class="object-cover w-full h-full" src="{{ author:email | gravatar }}" alt="">
{{ /if }}

I'm probably doing something weird with Antlers to make it happen.

Impacted Products Which Antlers Toolbox products does this bug apply to?

I don't understand the difference 🤔

Versions and Other Plugins/Extensions Please include the product version you are reporting a bug for. If you are reporting a bug for products such as Antlers Toolbox for VS Code or the Antlers Prettier Plugin, please include a list of other configured extensions or plugins if you believe they are contributing to the problematic behavior.

To Reproduce Format the above code block

Expected behavior The object-position and src to not be replaced with random strings.

If submitting a formatting bug, please include the template contents below as well as an attachment Add any problematic templates here.

Additional context N/A

JohnathonKoster commented 1 year ago

Thanks for the report! I will look into this and get a fix out sometime soon (and make it easier to select which product/version is impacted). 🙂

JohnathonKoster commented 1 year ago

Would you be able to share more of the template causing the issue? I am not able to reproduce with the provided sample using the VS Code formatter, or the prettier extension.

Thanks!

johncarter- commented 1 year ago

https://gist.github.com/johncarter-/e2032c4dff7f91e8a589af0eeb8ef62e

JohnathonKoster commented 1 year ago

Thanks for that! I was able to track down the issue - I will be working on making sure it doesn't trash thing when there is invalid Antlers.

However, in your template you have this:

{{ author_articles = collection:articles author:is="{author:id}" id:isnt="{id}" limit="3" }}

To assign the tag results to a variable you will need to wrap that in {}:

{{ author_articles = {collection:articles author:is="{author:id}" id:isnt="{id}" limit="3"} }}

That will correct the assignment behavior, as well as resolve the formatting bug 👍

johncarter- commented 1 year ago

Thank you so much John. You're a genuine legend.

JohnathonKoster commented 1 year ago

The original buggy behavior has been resolved in: