[Opinion] What is your prefered multi-line syntax style in HBS?


#1

I’ve seen a few different styles and I was wondering what others thought. Here are a two I personally flip between:

<AngleBracketComponent
    class="foobar"
    @fourSpaceIndent={{this.foo}}
    as |foo|>
  <TwoSpaceIndent
      class="bar"/>
  <p>Ending bracket stays on last line</p>
</AngleBracketComponent>

{{#curly-bracket-component
    class="foobar"
    fourSpaceIndent=this.foo
    as |foo|}}
  {{two-space-indent
      class="bar"}}
  <p>Ending bracket stays on last line</p>
{{/curly-bracket-component}}
<AngleBracketComponent
  class="foobar"
  @twoSpaceIndent={{this.foo}}
  as |foo|
>
  <TwoSpaceIndent
    class="bar"
  />
  <p>Ending bracket ends on next line</p>
</AngleBracketComponent>

{{#curly-bracket-component
  class="foobar"
  twoSpaceIndent=this.foo
  as |foo|
}}
  {{two-space-indent
    class="bar"
  }}
  <p>Ending bracket ends on next line</p>
{{/curly-bracket-component}}

#2

I prefer the second set, but I wouldn’t complain either way. Mostly I just care that everyone on the team is doing the same thing consistently.


#3

I also prefer the second set. I find it weird when there’s a reason to indent and there’s nothing to close out that indentation.