-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
When formatting Twig files using Prettier with the prettier-plugin-twig, I'm having trouble achieving the desired indentation for method chaining within a href attribute. Currently, the methods are not placed on new lines in a way that I find readable.
Here is the formatting result I get after using Prettier:
<a class="task-edit"
href="{{
ea_url().setDashboard(
'App\\Controller\\Dashboard\\DashboardController'
).setController(
'App\\Controller\\Dashboard\\CRUD\\TacheCrudController'
).setAction(
'edit'
).setEntityId(
tache.id
).set(
'sort',
null
)
}}">
<i class="fa-solid fa-edit"></i>
</a>
Expected Behavior :
I would like the formatter to break lines properly, with each method in the chain starting on a new line for better readability, as shown below:
<a class="task-edit"
href="{{
ea_url()
.setDashboard('App\\Controller\\Dashboard\\DashboardController')
.setController('App\\Controller\\Dashboard\\CRUD\\TacheCrudController')
.setAction('edit')
.setEntityId(tache.id)
.set('sort', null)
}}">
<i class="fa-solid fa-edit"></i>
</a>
Here is my current Prettier configuration:
{
"plugins": ["prettier-plugin-twig"],
"twigAlwaysBreakObjects": true,
"twigMultiLineObjects": true,
"printWidth": 80,
"tabWidth": 4,
"useTabs": false
}
Is this the expected behavior or am I misusing the plugin or Prettier's configuration? I suspect I may not fully understand how to configure Prettier or the plugin correctly to achieve my desired result.
I really appreciate the work you've done on this plugin! Thank you for your time! 😊