What is the common preference/recommendation in the community about using parentheses for function calls in Phoenix templates?

After a long period without doing anything related to Elixir/Phoenix I came back and just upgraded a former project to Phoenix 1.6. Many things have changed but I’m starting to get used to things again at my own pace. :turtle: ^^

Now I’m using heex templates and even added the HEEx HTML Formatter as plugin to mix format.

I see that this formatter plugin will add parentheses to any function call inside heex templates.

For example

<%= render “edit_profile.html”, some_func(assigns) %>

will become

<%= render(“edit_profile.html”, some_func(assigns)) %>

Personnally I find the first synthax prettier and less cumbersome.

And also when I used generators like phx.gen.auth they adopt the first style as well.

So my actual question is:

Is it just a matter of preference or is there a synthax that is encouraged or recommended inside templates?

Thanks. ^^

1 Like

I think it’s a matter of preference. But seeing as you asked, the correct preference is to use parentheses for all function calls and optionally, leave them off for macros :wink:

2 Likes