-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
This issue resurfaced in gohugoio/hugo#5604 -- but has been mentioned enough times to have proven its value.
In Hugo we have many variadic template functions. One relevant example would be the dict func that accepts a list of key/value pairs.
A current example would look like this:
{{ dict "country" "Norway" "population" "5 millions" "language" "Norwegian" "languageCode" "nb" "weather" "freezing cold" "capitol" "Oslo" "largest_city" "Oslo" "currency" "Norwegian krone" "dialing_code" "+47" }}The above would obviously be easier to read if it could be written something like this:
{{ dict
"country" "Norway"
"population" "5 millions"
"language" "Norwegian"
"language_code" "nb"
"weather" "freezing cold"
"capitol" "Oslo"
"largest_city" "Oslo"
"currency" "Norwegian krone"
"dialing_code" "+47"
}}The above creates a parser error, and is a common problem when you try to use one of the "HTML beautifiers" out there on Go templates.
As a person who have spent some thousand hours inside Go templates I would say that this issue is really, really worth it. And if you don't come from that background, I think it helps to be reminded that many Go applications needs a user interface, and Go templates is a natural choice. No one questions the value of gofmt and pretty Go code, not sure why the UI code should be treated differently. I know @natefinch tinkered with a "Go template formatter" some time ago. A solution to this partucular issue would make that task more enjoyable, me thinks.
/cc @regisphilibert