wearedestination / prettier-plugin-twig

Prettier Twig/HTML plugin
MIT License
4 stars 1 forks source link

Arrays and Objects Indentation #4

Open TomoyaHamasaki opened 4 months ago

TomoyaHamasaki commented 4 months ago

Any lead on how I can add indentation to arrays and objects in Twig? Keeps formatting sub arrays weird like below

This

{%
set defaultAttributes = {
    id: null,
    alt: null,
    class: 'w-full h-full rounded-lg aspect-square object-cover border bg-neutral image-preview',
    stimulus: {
        controllers: {
            target: 'target-name'
        }
    }
}
%}

Would turn into this

{%
    set defaultAttributes = {
    id: null,
    alt: null,
    class: 'w-full h-full rounded-lg aspect-square object-cover border bg-neutral image-preview',
    stimulus: {
    controllers: {}
    }
    }
%}

Awesome fork - best one out there.

BigglesZX commented 2 months ago

I'm also seeing this, I've never done any development on formatters but any tips as to where we might look to address this would be much appreciated. Thanks for your work on this plugin.

andyexeter commented 2 months ago

Until we can figure out a fix for this, does adding {# prettier-ignore #} above the opening {% help?

BigglesZX commented 2 months ago

@andyexeter Yes it does! Thanks for the tip. This should be fine for now.