prettydiff
prettydiff copied to clipboard
Beautify Twig Hash & Array
1. Hash
Source
{% include 'any.twig' with { 'foo':bar} %}
Expected
{% include 'any.twig' with { 'foo': bar } %}
Result
{% include 'any.twig' with { 'foo':bar} %}
2. Array
Source
{% set foo = [1,{"foo":"bar"}] %}
Expected
{% set foo = [1, {"foo": "bar"}] %}
Result
{% set foo = [1,{"foo":"bar"}] %}
I am not currently parsing the insides of the Twig tags, but I certainly should be. If I were to parse it similarly to how I parse JavaScript the output would look like:
Default presentation
<a>
{% include 'any.twig' with {
'foo' : bar
} %}
</a>
and
<a>
{% set foo = [
1, {
"foo": "bar"
}
] %}
</a>
Setting options format_array and format_object to value inline
<a>
{% include 'any.twig' with {
'foo' : bar,
'cat' : "meow"
} %}
</a>
<a>
{% include 'any.twig' = {
'foo': bar, 'cat': "meow"
} %}
</a>
and
<a>
{% set foo = [
1, {"foo": "bar"}
] %}
</a>
That looks neat! As long as it is consistent, I'm very happy.