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

Beautify Twig Hash & Array #615

Open
rubas opened this issue Aug 30, 2019 · 2 comments
Open

Beautify Twig Hash & Array #615

rubas opened this issue Aug 30, 2019 · 2 comments

Comments

@rubas
Copy link

rubas commented Aug 30, 2019

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"}] %}

@prettydiff
Copy link
Owner

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>

@rubas
Copy link
Author

rubas commented Sep 2, 2019

That looks neat! As long as it is consistent, I'm very happy.

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

No branches or pull requests

2 participants