NiklasPor / prettier-plugin-go-template

Fixes prettier formatting for go templates 🐹

Home Page:prettier-plugin-go-template-niklaspor.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conditional statements misaligned due to formatter breaking lines

gcushen opened this issue · comments

commented

Input

    {{ if not .Lastmod.IsZero }}<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}">{{ end }}

Output

    {{ if not .Lastmod.IsZero }}
      <meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}"
    />{{ end }}

{{ end }} is now misaligned with {{ if ... }} which can give the appearance that the rest of the file is within the IF statement.

Line Width Setting

printWidth: 120

Version: 0.0.10

After #49 is released the output will look like this:

{{ if not .Lastmod.IsZero }}
  <meta
    property="article:modified_time"
    content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}"
  />
{{ end }}

Does that look good to you @gcushen ?

commented

Does that look good to you @gcushen ?

Thanks, looks great - both the Go templating blocks and HTML blocks in your example are nicely aligned with themselves now! I'll try to test out the new release.