Skip to content

Commit

Permalink
hbs: update comment to remove line break (#59)
Browse files Browse the repository at this point in the history
Template languages that generate HTML files, like Handlebars, are often
sensitive to whitespace, so adding a line break may change how a page is
rendered.

This commit adds a `~` at the end of the comment as a whitespace control
so the rendering engine removes the additional line break added by the
license header comment.
  • Loading branch information
lgfa29 committed Apr 13, 2023
1 parent 39309b6 commit f7e1721
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addlicense/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func licenseHeader(path string, tmpl *template.Template, data LicenseData) ([]by
case ".hs", ".sql", ".sdl":
lic, err = executeTemplate(tmpl, data, "", "-- ", "")
case ".hbs":
lic, err = executeTemplate(tmpl, data, "{{!", " ", "}}")
lic, err = executeTemplate(tmpl, data, "{{!", " ", "~}}")
case ".html", ".htm", ".xml", ".vue", ".wxi", ".wxl", ".wxs":
lic, err = executeTemplate(tmpl, data, "<!--", " ", "-->")
case ".php":
Expand Down
2 changes: 1 addition & 1 deletion addlicense/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func TestLicenseHeader(t *testing.T) {
},
{
[]string{"f.hbs"},
"{{!\n HYS\n}}\n\n",
"{{!\n HYS\n~}}\n\n",
},
{
[]string{"f.html", "f.htm", "f.xml", "f.vue", "f.wxi", "f.wxl", "f.wxs"},
Expand Down

0 comments on commit f7e1721

Please sign in to comment.