Search code examples
twigprettier

Same line for path() and paragraph


I would like to know if it's possible to force prettier to write my "path" in one line:

This is what I have:

<a href="{{ path('product_conf', { slug: product.slug }) }}">

But prettier write this element like this:

<a href="{{
    path(
        'product_conf',
        {
            slug: product.slug
        }
    )
    }}">

Same for my h3, p, etc :

<h3>
    Let's go!
</h3>

(I would like: <h3> Let's go! </h3>)

My prettierrc.json

{
    "singleQuote": true,
    "useTabs": true,
    "printWidth": 180,
    "tabWidth": 2,
    "singleAttributePerLine": true,
    "plugins": [
        "./node_modules/prettier-plugin-twig-melody"
    ]
}

Solution

  • Add "twigAlwaysBreakObjects": false in your .prettierrc.json.